agones.dev/agones@v1.53.0/sdks/unity/Tests/Runtime/PlayMode/AgonesSdkComplianceTests.cs (about) 1 // Copyright 2024 Google LLC 2 // All Rights Reserved. 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 using System.Collections; 17 using System.Threading.Tasks; 18 using Agones; 19 using NUnit.Framework; 20 using Tests.TestingEnvironment; 21 using UnityEngine; 22 using UnityEngine.Networking; 23 using UnityEngine.TestTools; 24 25 namespace Tests.Runtime.Agones 26 { 27 public class AgonesSdkComplianceTests 28 { 29 [UnityTest] 30 public IEnumerator AgonesSdk_Ready_ShouldInteractWithReadyApiEndpoint() 31 { 32 var sut = new GameObject().AddComponent<AgonesSdk>(); 33 var spy = new SpyRequestSender(); 34 sut.requestSender = spy; 35 yield return null; 36 var task = sut.Ready(); 37 yield return AwaitTask(task); 38 Assert.IsTrue(spy.LastApi.Contains("/ready")); 39 Assert.IsTrue(spy.LastJson.Equals("{}")); 40 Assert.AreEqual(spy.LastMethod, UnityWebRequest.kHttpVerbPOST); 41 } 42 private IEnumerator AwaitTask(Task task) 43 { 44 while (!task.IsCompleted) 45 yield return null; 46 if (task.Exception != null) 47 throw task.Exception; 48 } 49 } 50 }