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(); }
protected void FailTestIfClientOutOfSync(string i_testName) { if (mBackend.IsClientOutOfSync()) { IntegrationTest.Fail(i_testName + ": Client should NOT be out of sync, but it is."); } }
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(); }
// this method is ugly...this whole thing is not great or flexible private void CheckAreaTypeMinimums(MapData i_mapData) { BackendManager.Backend.MakeCloudCall(CloudTestMethods.getDefaultMapAreaWeights.ToString(), null, (results) => { List <MapModification> defaultWeights = JsonConvert.DeserializeObject <List <MapModification> >(results[BackendConstants.DATA]); defaultWeights = RemoveNonMinimumsFromDefaults(defaultWeights); // now change the weights based on the modifications of the map data defaultWeights = ModifyDefaultWeightsFromMapPieces(defaultWeights, i_mapData.Name.Prefix); defaultWeights = ModifyDefaultWeightsFromMapPieces(defaultWeights, i_mapData.Name.Terrain); defaultWeights = ModifyDefaultWeightsFromMapPieces(defaultWeights, i_mapData.Name.Suffix); // decrement the minimum for a weight when it shows up -- NOT SAFE IF SOME TYPES NOT REPRESENTED foreach (MapAreaData areaData in i_mapData.Areas) { defaultWeights[(int)areaData.AreaType].Amount--; } foreach (MapModification defaultWeight in defaultWeights) { if (IsMinimumKey(defaultWeight.Key) && defaultWeight.Amount > 0) { IntegrationTest.Fail("Test map areas failed: Minimum not met for area type " + defaultWeight.Key + "(" + defaultWeight.Amount + ")"); } } }); }
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)); }
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); } }
void FixedUpdate() { switch (Option) //makes sure stuff like destination is always correct, instead of counting on unity's Start build order. { case 1: //tests movement from -2,0,0 to 0,0,0 ShipMovementTestInit(); break; case 2: //tests movement from -2,0,0 to 0,0,0 AND being in the same location as the points in the path ShipMovementTestInit(); if (_counter == 0) { PathsManager.Instance.DrawPath(Ship, Vector3.zero); } break; } switch (Option) { case 2: if (_counter < Ship.LineRenderer.numPositions && Ship.LineRenderer.GetPosition(_counter) != Ship.transform.position) { IntegrationTest.Fail(); } _counter++; break; } }
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 }
private IEnumerator Start() { IScanner scanner = new Scanner(); tweaker = new Tweaker(); TweakerOptions options = TweakerOptions.GetDefaultWithAdditionalFlags(TweakerOptionFlags.IncludeTests); tweaker.Init(options, scanner); AutoTweakable.Manager = tweaker.Tweakables; new TestClass(disposeTweakable: false); ITweakable tweakable = tweaker.Tweakables.GetTweakable(new SearchOptions("TestClass.AutoInt#")); IntegrationTest.Assert(tweakable != null); uint counter = 0u; while (tweaker.Tweakables.GetTweakable(new SearchOptions("TestClass.AutoInt#")) != null) { GC.Collect(); counter++; if (counter > 1000) { IntegrationTest.Fail("Failed to finalize AutoTweakable after " + counter + " frames."); yield break; } yield return(null); } IntegrationTest.Pass(); }
protected IEnumerator login() { MixLoginCreateService mixLoginCreateService = Service.Get <MixLoginCreateService>(); bool done = false; Action <ISession> onSuccess = null; Action <ILoginResult> onFailed = null; onSuccess = delegate(ISession s) { mixLoginCreateService.OnLoginSuccess -= onSuccess; mixLoginCreateService.OnLoginFailed -= onFailed; Service.Get <SessionManager>().AddMixSession(s); done = true; }; onFailed = delegate(ILoginResult r) { mixLoginCreateService.OnLoginSuccess -= onSuccess; mixLoginCreateService.OnLoginFailed -= onFailed; IntegrationTest.Fail(string.Concat("Couldn't create a session [", r, "] ")); done = true; }; mixLoginCreateService.OnLoginSuccess += onSuccess; mixLoginCreateService.OnLoginFailed += onFailed; mixLoginCreateService.Login("dtdev1011a", "testing123"); while (!done) { yield return(null); } }
protected override IEnumerator runTest() { string payload = string.Format("{0}embeddedasseta.txt?dl=bundle:mock-create-bundle&b=embedded_asset_test&x=.txt", "assets/rootassets/"); ContentManifest.AssetEntry entry = ContentManifest.AssetEntry.Parse(payload); BundleManager bundleManager = new BundleManager(null); DeviceManager deviceManager = new DeviceManager(); deviceManager.Mount(new BundleDevice(deviceManager, bundleManager)); AssetRequest <TextAsset> request = deviceManager.LoadAsync <TextAsset>(entry.DeviceList, ref entry); if (request == null) { IntegrationTest.Fail("request == null"); } else if (bundleManager.IsMounted(entry.BundleKey)) { IntegrationTest.Fail("Bundle will not be mounted untill after the AssetBundle is created internally."); } else { yield return(request); IntegrationTest.Assert(bundleManager.IsMounted(entry.BundleKey)); IntegrationTest.Assert(request.Asset != null); bundleManager.UnmountBundle(entry.BundleKey, unloadAllLoadedObjects: false); } bundleManager.UnmountAllBundles(); }
private void FailIfSaveDataNotEmpty(string i_saveData, string i_saveKey) { if (i_saveData != EMPTY_SAVE_DATA) { IntegrationTest.Fail("Save data should be empty but it wasn't: " + i_saveKey); } }
private void VerifyMissionProgressIsDefault(string i_saveData) { Dictionary <string, string> cloudParams = new Dictionary <string, string>() { { BackendConstants.SAVE_KEY, BackendConstants.MISSION_PROGRESS } }; mBackend.MakeCloudCall(CloudTestMethods.getReadOnlyData.ToString(), cloudParams, (results) => { Dictionary <string, WorldMissionProgress> allMissionProgress = JsonConvert.DeserializeObject <Dictionary <string, WorldMissionProgress> >(results[BackendConstants.DATA]); WorldMissionProgress baseWorldMissionProgress = allMissionProgress[BackendConstants.WORLD_BASE]; if (baseWorldMissionProgress.Missions.Count != IntegrationTestUtils.DEFAULT_MAP_SIZE) { IntegrationTest.Fail("Missions completed list was not default: " + baseWorldMissionProgress.Missions.Count); } foreach (SingleMissionProgress singleMission in baseWorldMissionProgress.Missions) { if (singleMission.Completed != false) { IntegrationTest.Fail("A mission was marked as completed when it should not have been."); } } }); }
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() { 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(); } } }
// how to improve this? Make the parts of the map name into an array? private void CheckMapNames(MapName i_mapName, int i_level) { if (i_mapName.Prefix.PieceType != MapPieceTypes.Prefix) { IntegrationTest.Fail("Map name test failed: Prefix piece type was " + i_mapName.Prefix.PieceType + " and not " + MapPieceTypes.Prefix); } if (!i_mapName.Prefix.LevelRestriction.DoesPass(i_level)) { IntegrationTest.Fail("Map name test failed: Prefix level not valid"); } if (i_mapName.Terrain.PieceType != MapPieceTypes.Terrain) { IntegrationTest.Fail("Map name test failed: Terrain piece type was " + i_mapName.Terrain.PieceType + " and not " + MapPieceTypes.Terrain); } if (!i_mapName.Terrain.LevelRestriction.DoesPass(i_level)) { IntegrationTest.Fail("Map name test failed: Terrain level not valid"); } if (i_mapName.Suffix.PieceType != MapPieceTypes.Suffix) { IntegrationTest.Fail("Map name test failed: Suffix piece type was " + i_mapName.Suffix.PieceType + " and not " + MapPieceTypes.Suffix); } if (!i_mapName.Suffix.LevelRestriction.DoesPass(i_level)) { IntegrationTest.Fail("Map name test failed: Suffix level not valid"); } }
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."); } }
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(); } }
// 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(); } }
//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); }
public static void FailIf(bool condition, string message) { if (condition) { IntegrationTest.Fail(message); } }
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); }
public static void FailIf(GameObject go, bool condition, string message) { if (condition) { IntegrationTest.Fail(go, message); } }
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(); }
private void CheckAreasSize(MapData i_mapData, int i_size) { if (i_mapData.Areas.Count != i_size) { IntegrationTest.Fail("Test map areas fail: Expecting " + i_size + " areas but there were " + i_mapData.Areas.Count); } }