private IEnumerator runTests() { frameCount = 0; yield return(RadicalCoroutine.Run(this, waitForSecondsTest(), "waitForSecondsTest")); frameCount = 0; yield return(RadicalCoroutine.Run(this, waitForNextFrameTest(), "waitForNextFrameTest")); frameCount = 0; yield return(RadicalCoroutine.Run(this, waitForFrameTest(), "waitForFrameTest")); frameCount = 0; yield return(RadicalCoroutine.Run(this, waitForCompositeReturnTest(), "waitForCompositeReturn")); yield return(RadicalCoroutine.Run(this, waitForFrameCancelledTest(), "waitForFrameCancelledTest")); yield return(RadicalCoroutine.Run(this, waitForDisposedEventTest(), "WaitForDisposedEventTest")); yield return(RadicalCoroutine.Run(this, waitForCompletedEventTest(), "waitForCompletedEventTest")); yield return(RadicalCoroutine.Run(this, waitForPausedEventTest(), "waitForPausedEventTest")); yield return(RadicalCoroutine.Run(this, waitForResumedEventTest(), "waitForResumedEventTest")); yield return(RadicalCoroutine.Run(this, cannotAddListenerToEmptyEnumerator(), "cannotAddListenerToEmptyEnumerator")); yield return(RadicalCoroutine.Run(this, waitForNestedIEnumeratorTest(), "waitForNestedIEnumeratorTest")); IntegrationTest.Pass(); }
/// <summary> /// WIP todo full integration tests /// </summary> // [Fact] public void IndexAdmin() { // arrange var server = IntegrationTest.RunTestHost(); var client = server.CreateClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Test"); // // var user = IntegrationTest.MockUsers("Admin").GetAwaiter().GetResult(); // Thread.CurrentPrincipal = user.Principal; // var controller = mocker.CreateInstance<HomeController>(); var request = new HttpRequestMessage(HttpMethod.Post, "/Home"); request.Headers.Authorization = new AuthenticationHeaderValue("Test"); // Act var response = client.SendAsync(request).GetAwaiter().GetResult(); // Assert var responseString = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); Assert.Contains("Pavlov Rcon Webserver", responseString); Assert.Contains("User Management", responseString); Assert.Contains("Servers", responseString); Assert.Contains("Matchmaking", responseString); //DefaultDB(true); }
public void CheckTestResult() { if (flowchart == null) { IntegrationTest.Fail("Flowchart object not selected"); return; } // Check Fungus variables are populated with expected values if (flowchart.GetVariable <BooleanVariable>("BoolVar").value != true || flowchart.GetVariable <IntegerVariable>("IntVar").value != 5 || flowchart.GetVariable <FloatVariable>("FloatVar").value != 22.1f || flowchart.GetVariable <StringVariable>("StringVar").value != "a string") { IntegrationTest.Fail("Fungus variables do not match expected values"); return; } // Check the right number of methods were invoked successfully if (passCount == 11) { IntegrationTest.Pass(); } else { IntegrationTest.Fail("A method did not get invoked or parameter was incorrect"); } }
private void OnFadeInCompleteCallback() { if (audioPlayer.AudioSource.volume == 1) { IntegrationTest.Pass(gameObject); } }
private IEnumerator TestEmojiInText(Text textComponent, string emojiString) { chatInputField.text = emojiString; yield return(null); IntegrationTest.Assert(textComponent.preferredWidth > 0f, "Failed for emojiString: " + emojiString); }
private IEnumerator TestQueueInit() { for (int i = 0; i < m_SpawnCount; i++) { m_Pool.Instantiate(); } yield return(new WaitForSeconds(2.5f)); for (int i = 0; i < m_SpawnCount; i++) { m_Pool.Instantiate(); } if (transform.childCount > m_SpawnCount) { IntegrationTest.Fail("To many prefabs were created"); } else if (transform.childCount < m_SpawnCount) { IntegrationTest.Fail("To few prefabs were created"); } else { IntegrationTest.Pass(); } }
private void Start() { IntegrationTestManager testManager = new IntegrationTestManager(); Mesh mesh = testManager.mesh; testManager.CreateBox(); mesh.vertices.BuildVertices(); mesh.triangles.BuildTriangles(); ExportObj exportObj = new ExportObj(); exportObj.vertices = mesh.uMesh.vertices; exportObj.triangles = mesh.triangles.triangles.ToArray(); exportObj.materials = mesh.materials.GetMaterials(); exportObj.materialNames = mesh.materials.MaterialNames(); exportObj.Save("Temp/test.obj"); ImportObj importObj = new ImportObj(); importObj.Load("Temp/test.obj"); testManager.Assert(importObj.vertices.Count == 8); testManager.Assert(importObj.triangles.Count == 12 * 3); testManager.Assert(importObj.materialNames.Count == 12); testManager.Assert(importObj.materials.Count == 1); testManager.Assert(File.Exists("Temp/test.obj")); File.Delete("Temp/test.obj"); testManager.Assert(File.Exists("Temp/test.mtl")); File.Delete("Temp/test.mtl"); IntegrationTest.Pass(gameObject); }
void OnCommandExecute(Block block, Command command, int commandIndex, int maxCommandIndex) { IntegrationTest.Assert(commandIndex == 0); IntegrationTest.Assert(maxCommandIndex == 1); IntegrationTest.Assert(command.GetType() == typeof(Wait)); commandExecuted = true; }
void Update() { IntegrationTest.Assert(card.GetComponent <HasPhysicalCard>().PhysicalCardGO != null); IntegrationTest.Assert(card.GetComponent <HasOutline>().OutlineGO != null); Destroy(card); IntegrationTest.Pass(gameObject); }
private IEnumerator TestFaderObjectRemoval() { yield return(new WaitForFixedUpdate()); IntegrationTest.Assert(GameObject.Find("Fade") == null, "Fader game object should be removed at the end of fading"); IntegrationTest.Pass(); }
void OnBlockEnd(Block block) { IntegrationTest.Assert(started); IntegrationTest.Assert(commandExecuted); IntegrationTest.Pass(); }
protected override IEnumerator runTest() { BundleMount bundleMount = loadAndMount("DependencyBundlesTest/main.unity3d", null, isDependency: false); BundleMount bundleMount2 = loadAndMount("DependencyBundlesTest/dep1.unity3d", new HashSet <BundleMount> { bundleMount }, isDependency: true); BundleMount bundleMount3 = loadAndMount("DependencyBundlesTest/dep2.unity3d", new HashSet <BundleMount> { bundleMount2, bundleMount }, isDependency: true); bundleMount.IsPinned = true; IntegrationTest.Assert(bundleMount.IsPinned, "DependencyBundlesTest/main.unity3d"); IntegrationTest.Assert(bundleMount2.IsPinned, "DependencyBundlesTest/dep1.unity3d"); IntegrationTest.Assert(bundleMount3.IsPinned, "DependencyBundlesTest/dep2.unity3d"); bundleMount.IsPinned = false; IntegrationTest.Assert(!bundleMount.IsPinned, "DependencyBundlesTest/main.unity3d"); IntegrationTest.Assert(bundleMount2.IsPinned, "DependencyBundlesTest/dep1.unity3d"); IntegrationTest.Assert(bundleMount3.IsPinned, "DependencyBundlesTest/dep2.unity3d"); bundleMount3.IsPinned = true; IntegrationTest.Assert(!bundleMount.IsPinned, "DependencyBundlesTest/main.unity3d"); IntegrationTest.Assert(bundleMount2.IsPinned, "DependencyBundlesTest/dep1.unity3d"); IntegrationTest.Assert(bundleMount3.IsPinned, "DependencyBundlesTest/dep2.unity3d"); bundleMount.Unload(unloadAllLoadedObjects: true); bundleMount2.Unload(unloadAllLoadedObjects: true); bundleMount3.Unload(unloadAllLoadedObjects: true); yield break; }
protected override IEnumerator runTest() { string key = "embedded_asset_test"; TextAsset bundleTxt = Resources.Load <TextAsset>(key + ".unity3d"); AssetBundle bundle = AssetBundle.LoadFromMemory(bundleTxt.bytes); BundleManager manager = Content.BundleManager; BundleMount mount = manager.MountBundle(key, bundle); AsyncAssetBundleRequest <TextAsset> assetRequest = mount.LoadAsync <TextAsset>("embeddedasseta", "embeddedasseta.txt"); manager.UnmountBundle(key, unloadAllLoadedObjects: false); if (manager.IsMounted(key)) { IntegrationTest.Fail("Bundle should not be considered mounted while waiting to unmount."); } if (!manager.IsUnmounting(key)) { IntegrationTest.Fail("Bundle should be in the process of unmounting."); } yield return(assetRequest); if (assetRequest.Asset == null) { IntegrationTest.Fail("Failed to load asset"); } yield return(null); IntegrationTest.Assert(!manager.IsMounted(key)); IntegrationTest.Assert(!manager.IsUnmounting(key)); }
public void TakeDamage(int amount) //When enemy deal damage, THEY will call this function { //for unit testing int previousHealth = currentHealth; currentHealth -= amount; if (currentHealth < 0) { currentHealth = 0; } if (currentHealth != previousHealth - amount) { IntegrationTest.Fail(gameObject); } IntegrationTest.Pass(gameObject); healthSlider.value = currentHealth; //Adjusting the player's health bar UI if (currentHealth <= 0 && !isDead) { Death(); } }
// Update is called once per frame void Update() { if (other != null && Time.time > nextTime && Time.time <= maxTime) { if (ai.enabled) { IntegrationTest.Fail(); } else { check = true; nextTime++; } } if (Time.time > (maxTime + 0.1f) && check) { if (ai.enabled) { IntegrationTest.Pass(); } else { IntegrationTest.Fail(); } } }
//To test whether the correct side has been wiped after activation public void KillOneSideTest(bool playerFacing) { GameObject[] testEnemy; EnemyMovement enemyMovement; testEnemy = GameObject.FindGameObjectsWithTag("Enemy"); //There should be no more enemy for (int i = 0; i < testEnemy.Length; i++) { if (playerFacing) { if (testEnemy[i].transform.position.x > player.transform.position.x) { enemyMovement = testEnemy [i].GetComponent <EnemyMovement> (); if (enemyMovement.speed != 0) { IntegrationTest.Fail(gameObject); } } } else { if (testEnemy[i].transform.position.x < player.transform.position.x) { enemyMovement = testEnemy [i].GetComponent <EnemyMovement> (); if (enemyMovement.speed != 0) { IntegrationTest.Fail(gameObject); } } } } IntegrationTest.Pass(gameObject); }
protected override IEnumerator runTest() { string payload = string.Format("{0}?dl=bytes:mock-text-asset", "Configuration/embedded_content_manifest"); ContentManifest.AssetEntry entry = ContentManifest.AssetEntry.Parse(payload); DeviceManager manager = new DeviceManager(); manager.Mount(new MockTextAssetDevice(manager)); manager.Mount(new BytesDevice(manager)); AssetRequest <byte[]> request = manager.LoadAsync <byte[]>(entry.DeviceList, ref entry); if (request == null) { IntegrationTest.Fail("request == null"); yield break; } yield return(request); IntegrationTestEx.FailIf(!request.Finished); IntegrationTestEx.FailIf(request.Cancelled); IntegrationTestEx.FailIf(request.Asset == null); IntegrationTestEx.FailIf(request.Asset == null); if (request.Asset != null) { string key = entry.Key; byte[] bytes = Resources.Load <TextAsset>(key).bytes; IntegrationTestEx.FailIf(!request.Asset.SequenceEqual(bytes)); } IntegrationTest.Pass(); }
void testMovement() { if (startingY != GetComponent <Transform>().position.y) { IntegrationTest.Fail(gameObject); } else { IntegrationTest.Pass(gameObject); } if (startingZ != GetComponent <Transform>().position.z) { IntegrationTest.Fail(gameObject); } else { IntegrationTest.Pass(gameObject); } if (startingX == GetComponent <Transform>().position.x) { IntegrationTest.Fail(gameObject); } else { IntegrationTest.Pass(gameObject); } }
/// <summary> /// Event like FixedUpdate /// </summary> public void PlatformerUpdate(float delta) { if (UpdateManager.instance.runningTime > testDuration) { IntegrationTest.Pass(gameObject); } }
public IEnumerator StateMachine() { TestRunnerCallback.RunStarted(Application.platform.ToString(), testToRun); while (true) { if (testToRunQueue.Count == 0 && currentTest == null) { FinishTestRun(); break; } if (currentTest == null) { StartNewTest(); } if (currentTest != null) { if (testState == TestState.Running) { if (assertionsToCheck != null && assertionsToCheck.All(a => a.checksPerformed > 0)) { IntegrationTest.Pass(currentTest.go); testState = TestState.Success; } if (currentTest != null && Time.time > startTime + currentTest.TestComponent.timeout) { testState = TestState.Timeout; } } switch (testState) { case TestState.Success: LogMessage(finishedMessage); FinishTest(TestResult.ResultType.Success); break; case TestState.Failure: LogMessage(failedMessage); FinishTest(TestResult.ResultType.Failed); break; case TestState.Exception: LogMessage(failedExceptionMessage); FinishTest(TestResult.ResultType.FailedException); break; case TestState.Timeout: LogMessage(timeoutMessage); FinishTest(TestResult.ResultType.Timeout); break; case TestState.Ignored: LogMessage(ignoredMessage); FinishTest(TestResult.ResultType.Ignored); break; } } yield return(null); } }
private void OnIncComplete() { Assert.AreEqual(_incLoopCount, _incLoopsTotal, string.Format("Increase Loop count mismatch. Got {0}, expected {1}", _incLoopCount, _incLoopsTotal)); // This is the longest test, so it will call Success if it passes IntegrationTest.Pass(); }
protected override void Check() { if (rb != null) { IntegrationTest.Pass(gameObject); } }
IEnumerator Run() { GlobalCompositionRoot.Instance.EnsureIsInitialized(); var testMethods = this.GetType().GetAllMethods( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) .Where(x => x.GetCustomAttributes(typeof(InstallerTestAttribute), false).Any()).ToList(); foreach (var method in testMethods) { var wrapper = new InstallerWrapper(); wrapper.InstallCallback = () => { Container = wrapper.GetContainer(); method.Invoke(this, new object[0]); }; var settings = new SceneCompositionRoot.StaticSettings() { Installers = new List <IInstaller>() { wrapper }, ParentNewObjectsUnderRoot = true, OnlyInjectWhenActive = true, }; var oldRootObjects = this.gameObject.scene.GetRootGameObjects(); var root = SceneCompositionRoot.Instantiate(gameObject, settings); // Wait a few frames to have it start up yield return(null); yield return(null); yield return(null); yield return(null); GameObject.Destroy(root.gameObject); foreach (Transform childTransform in this.gameObject.transform) { GameObject.Destroy(childTransform.gameObject); } foreach (var obj in this.gameObject.scene.GetRootGameObjects().Except(oldRootObjects)) { GameObject.Destroy(obj); } yield return(null); Log.Trace("Installer Test '{0}' passed successfully", method.Name); } Log.Trace("All Installer Tests passed successfully"); IntegrationTest.Pass(); }
private IEnumerable login(TestGuest guest, Action <ISession> callback) { ISession session = null; bool done = false; Action <ISession> onSuccess = null; Action <ILoginResult> onFailed = null; onSuccess = delegate(ISession s) { mixLoginCreateService.OnLoginSuccess -= onSuccess; mixLoginCreateService.OnLoginFailed -= onFailed; session = s; done = true; }; onFailed = delegate { mixLoginCreateService.OnLoginSuccess -= onSuccess; mixLoginCreateService.OnLoginFailed -= onFailed; IntegrationTest.Fail("Couldn't create a session"); done = true; }; mixLoginCreateService.OnLoginSuccess += onSuccess; mixLoginCreateService.OnLoginFailed += onFailed; mixLoginCreateService.Login(guest.Username, guest.Password); while (!done) { yield return(null); } callback(session); }
void Update() { if (UpdateCount == 0) { IntegrationTest.Assert(_outline.WantedColor.a <= 0.0f); } else if (UpdateCount == 1) { _outline.Request(this, Color.red); } else if (UpdateCount == 2) { IntegrationTest.Assert(_outline.WantedColor == Color.red); _outline.Request(_outline, Color.black); } else if (UpdateCount == 3) { IntegrationTest.Assert(_outline.WantedColor == Color.red); _outline.Revoke(this); } else if (UpdateCount == 4) { IntegrationTest.Assert(_outline.WantedColor == Color.black); Destroy(_card); IntegrationTest.Pass(gameObject); } UpdateCount++; }
protected override IEnumerator runTest() { string testPath = Path.Combine(Directory.GetCurrentDirectory(), "Assets/Generated/Resources/Configuration/embedded_content_manifest.txt"); string payload = $"{testPath}?dl=file-bytes&x=txt"; ContentManifest.AssetEntry entry = ContentManifest.AssetEntry.Parse(payload); DeviceManager manager = new DeviceManager(); manager.Mount(new FileBytesDevice(manager)); AssetRequest <byte[]> request = manager.LoadAsync <byte[]>(entry.DeviceList, ref entry); if (request == null) { IntegrationTest.Fail("request == null"); } else { yield return(request); IntegrationTestEx.FailIf(!request.Finished); IntegrationTestEx.FailIf(request.Cancelled); IntegrationTestEx.FailIf(request.Asset == null); IntegrationTestEx.FailIf(request.Asset == null); string path = "Configuration/embedded_content_manifest.json"; IntegrationTestEx.FailIf(!Enumerable.SequenceEqual(second: Resources.Load <TextAsset>(path).bytes, first: request.Asset)); } IntegrationTest.Pass(); }
void Update() { if (UpdateCount == 0) { IntegrationTest.Assert(_mouse_over.MouseOver == false); } else if (UpdateCount == 1) { Vector3 middle_of_screen = new Vector3(Screen.width * 0.5f, Screen.height * 0.5f, 0.0f); UnityBridge.Instance.OverrideMousePosition(true, middle_of_screen); } else if (UpdateCount == 2) { IntegrationTest.Assert(_mouse_over.MouserOverPreviousFrame == false); IntegrationTest.Assert(_mouse_over.MouseOver == true); } else if (UpdateCount == 3) { Vector3 left_of_screen = new Vector3(Screen.width * 0.25f, Screen.height * 0.5f, 0.0f); UnityBridge.Instance.OverrideMousePosition(true, left_of_screen); } else if (UpdateCount == 4) { IntegrationTest.Assert(_mouse_over.MouserOverPreviousFrame == true); IntegrationTest.Assert(_mouse_over.MouseOver == false); Destroy(_card); IntegrationTest.Pass(gameObject); } UpdateCount++; }
protected override IEnumerator runTest() { string payload = $"embeddedasseta?dl=bundle:mock-create-bundle&b=embedded_asset_test&x=.txt"; ContentManifest.AssetEntry entry = ContentManifest.AssetEntry.Parse(payload); BundleManager bundleManager = new BundleManager(null); DeviceManager deviceManager = new DeviceManager(); deviceManager.Mount(new BundleDevice(deviceManager, bundleManager)); AssetRequest <TextAsset> requestA = deviceManager.LoadAsync <TextAsset>(entry.DeviceList, ref entry); AssetRequest <TextAsset> requestB = deviceManager.LoadAsync <TextAsset>(entry.DeviceList, ref entry); if (requestA == null || requestB == null) { IntegrationTest.Fail("requestA == null"); } else { yield return(requestA); yield return(requestB); IntegrationTestEx.FailIf(requestA.Asset == null); IntegrationTestEx.FailIf(requestB.Asset == null); IntegrationTest.Pass(); } bundleManager.UnmountAllBundles(); }
protected override IEnumerator runTest() { string payload = string.Format("{0}?dl=json:mock-json-res&x=txt", "Configuration/embedded_content_manifest"); ContentManifest.AssetEntry entry = ContentManifest.AssetEntry.Parse(payload); DeviceManager manager = new DeviceManager(); manager.Mount(new MockJsonResourceDevice(manager)); manager.Mount(new JsonDevice(manager)); AssetRequest <ContentManifest> request = manager.LoadAsync <ContentManifest>(entry.DeviceList, ref entry); if (request == null) { IntegrationTest.Fail("request == null"); } else { yield return(request); IntegrationTestEx.FailIf(!request.Finished); IntegrationTestEx.FailIf(request.Cancelled); IntegrationTestEx.FailIf(request.Asset == null); if (request.Asset == null) { } } IntegrationTest.Pass(); }
void Update() { _manager.Validate(); //If we reach the end of the recording, we pass! if (!_provider.IsPlaying) { _provider.DestroyShapes(); if ((allCallbacksRecieved & expectedCallbacks) == expectedCallbacks) { IntegrationTest.Pass(); return; } Debug.LogError(getEnumMessage("Expected callbacks: " + expectedCallbacks, expectedCallbacks)); Debug.LogError(getEnumMessage("Recieved callbacks: " + allCallbacksRecieved, allCallbacksRecieved)); IntegrationTest.Fail("Could not find an interaction behaviour that recieved all expected callbacks"); } #if UNITY_EDITOR else { // Show Gizmos for InteractionBrushBone. InteractionBrushBone[] bb = FindObjectsOfType(typeof(InteractionBrushBone)) as InteractionBrushBone[]; GameObject[] objs = new GameObject[bb.Length]; for (int i = 0; i < bb.Length; i++) { objs[i] = bb[i].gameObject; } Selection.objects = objs; } #endif }