private IEnumerator TestRoutine() { for (int i = 0; i < 10; i++) { GameObject go = m_Pool.Instantiate(); go.transform.SetParent(transform); PooledObject pooled = go.GetComponent <PooledObject>(); yield return(new WaitForSeconds(0.05f)); pooled.Deallocate(); yield return(new WaitForSeconds(0.05f)); } yield return(new WaitForSeconds(0.5f)); if (transform.childCount < 2) { //We should just reuse the same object IntegrationTest.Pass(); } else { IntegrationTest.Fail(gameObject, "Too many children were spawned. There should only be one."); } }
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++; }
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 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); }
private void OnFadeInCompleteCallback() { if (audioPlayer.AudioSource.volume == 1) { IntegrationTest.Pass(gameObject); } }
// 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(); } } }
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 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(); }
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(); } }
private void Start() { httpClient = new UnityHttpClient(); httpClient.DownloadInProgress.AddListener((UnityHttpClient client, DownloadInProgressEventArgs e) => { float progress = (float)e.BytesRead / e.TotalLength; Debug.Log(progress); }); httpClient.DownloadCompleted.AddListener((UnityHttpClient client, DownloadCompletedEventArgs e) => { UnityHttpResponse resp = (UnityHttpResponse)e.Response; Debug.LogFormat("HTTP Status Code: {0}", resp.StatusCode); Debug.LogFormat("HTTP Response Data: {0}", resp.Text); IntegrationTest.Pass(); }); httpClient.ErrorReceived.AddListener((UnityHttpClient client, HttpErrorReceivedEventArgs e) => { Debug.LogError(e.ErrorMessage); IntegrationTest.Fail(); }); httpClient.ExceptionCaught.AddListener((UnityHttpClient client, HandledExceptionEventArgs e) => { Debug.LogException(e.Exception); IntegrationTest.Fail(); }); UnityHttpRequest req = new UnityHttpRequest("http://www.baidu.com/"); httpClient.SendRequest(req); }
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 }
public IEnumerator DoPublishNoStore(string testName) { pubnub = new Pubnub(CommonIntergrationTests.PublishKey, CommonIntergrationTests.SubscribeKey); System.Random r = new System.Random(); string ch = "UnityIntegrationTest_CH_" + r.Next(100); string uuid = "UnityIntegrationTest_UUID"; pubnub.ChangeUUID(uuid); string pubMessage = "TestMessageNoStore" + r.Next(100); pubnub.Publish(ch, pubMessage, false, (string retM) => { pubnub.DetailedHistory(ch, 1, (string retM2) => { UnityEngine.Debug.Log(string.Format("retM2: {0}", retM2)); if (!retM2.Contains(pubMessage)) { IntegrationTest.Pass(); } else { IntegrationTest.Fail(); } }, this.DisplayErrorMessage); }, this.DisplayErrorMessage); yield return(new WaitForSeconds(CommonIntergrationTests.WaitTimeBetweenCallsLow)); pubnub.EndPendingRequests(); pubnub.CleanUp(); }
private IEnumerator LoginUserTest() { user.Password = PASSWORD; yield return(user.Login(onUserSuccess, onUserFailure)); IntegrationTest.Pass(); }
// Use this for initialization void Start() { dashbutton = FindObjectOfType <DashButtonController> (); player = FindObjectOfType <PlayerMovement> (); pressDashButton(); // check if player dashes when button is pressed if (!player.isDashing()) { Debug.Log("Player is not dashing incorrectly"); IntegrationTest.Fail(); } else { IntegrationTest.Pass(); } releaseDashButton(); // check player does not dash when button released if (!player.isDashing()) { Debug.Log("player is not dashing correctly"); IntegrationTest.Pass(); } else { IntegrationTest.Fail(); } }
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(); }
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(); }
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(); }
void OnBlockEnd(Block block) { IntegrationTest.Assert(started); IntegrationTest.Assert(commandExecuted); IntegrationTest.Pass(); }
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 Update() { IntegrationTest.Assert(card.GetComponent <HasPhysicalCard>().PhysicalCardGO != null); IntegrationTest.Assert(card.GetComponent <HasOutline>().OutlineGO != null); Destroy(card); IntegrationTest.Pass(gameObject); }
/// <summary> /// Event like FixedUpdate /// </summary> public void PlatformerUpdate(float delta) { if (UpdateManager.instance.runningTime > testDuration) { IntegrationTest.Pass(gameObject); } }
//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); }
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(); }
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); } }
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(); }
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); } }
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 void Check() { if (rb != null) { IntegrationTest.Pass(gameObject); } }
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() { CallTest -= Time.deltaTime; if (CallTest - ConfigurationManager.FloatingPoint <= 0) { switch (Option) { case 1: if (Ship.transform.position == Vector3.zero) { _pass = true; } break; case 2: //fail case in fixed update _pass = true; break; case 3: _pass = Ship.Health == (_counter - ((Missile)SO).Damage); break; } if (_pass) { IntegrationTest.Pass(); } else { IntegrationTest.Fail(); } } }