public void Instance2Login(UUnitTestContext testContext) { var loginRequest = new LoginWithCustomIDRequest { CustomId = PlayFabSettings.BuildIdentifier, CreateAccount = true, }; var loginTask = client2.LoginWithCustomIDAsync(loginRequest); loginTask.Wait(); testContext.True(player2.IsClientLoggedIn(), "player2 client login failed, "); testContext.True(client2.IsClientLoggedIn(), "client2 client login failed"); testContext.True(player2.IsEntityLoggedIn(), "player2 entity login failed"); testContext.True(auth2.IsEntityLoggedIn(), "auth2 entity login failed"); testContext.False(PlayFabClientAPI.IsClientLoggedIn(), "p2 client context leaked to static context"); testContext.False(PlayFabAuthenticationAPI.IsEntityLoggedIn(), "p2 entity context leaked to static context"); // Verify useful player information testContext.NotNull(player2.PlayFabId); testContext.NotNull(player2.EntityId); testContext.NotNull(player2.EntityType); testContext.EndTest(UUnitFinishState.PASSED, PlayFabSettings.staticSettings.TitleId + ", " + loginTask.Result.Result.PlayFabId); }
public void PluginManagerMultiplePluginsPerContract(UUnitTestContext testContext) { const string customTransportName1 = "Custom transport client 1"; const string customTransportName2 = "Custom transport client 2"; var playFabTransport = PluginManager.GetPlugin <ITransportPlugin>(PluginContract.PlayFab_Transport); var expectedTransport1 = new CustomTransportPlugin() { Name = customTransportName1 }; var expectedTransport2 = new CustomTransportPlugin() { Name = customTransportName2 }; // Set custom plugins PluginManager.SetPlugin(expectedTransport1, PluginContract.PlayFab_Transport, customTransportName1); PluginManager.SetPlugin(expectedTransport2, PluginContract.PlayFab_Transport, customTransportName2); // Verify var actualTransport = PluginManager.GetPlugin <ITransportPlugin>(PluginContract.PlayFab_Transport); testContext.True(object.ReferenceEquals(actualTransport, playFabTransport)); // the default one is still the same var actualTransport1 = PluginManager.GetPlugin <ITransportPlugin>(PluginContract.PlayFab_Transport, customTransportName1); testContext.True(object.ReferenceEquals(actualTransport1, expectedTransport1)); var actualTransport2 = PluginManager.GetPlugin <ITransportPlugin>(PluginContract.PlayFab_Transport, customTransportName2); testContext.True(object.ReferenceEquals(actualTransport2, expectedTransport2)); testContext.EndTest(UUnitFinishState.PASSED, null); }
public void StaticLogin(UUnitTestContext testContext) { var loginRequest = new LoginWithCustomIDRequest { CustomId = PlayFabSettings.BuildIdentifier, CreateAccount = true, }; var loginTask = PlayFabClientAPI.LoginWithCustomIDAsync(loginRequest); loginTask.Wait(); testContext.True(PlayFabClientAPI.IsClientLoggedIn(), "p2 client context leaked to static context"); testContext.True(PlayFabAuthenticationAPI.IsEntityLoggedIn(), "p2 entity context leaked to static context"); testContext.False(client1.IsClientLoggedIn(), "Static login leaked to Client1"); testContext.False(client2.IsClientLoggedIn(), "tatic login leaked to Client2"); testContext.False(auth1.IsEntityLoggedIn(), "Static login leaked to Auth1"); testContext.False(auth2.IsEntityLoggedIn(), "Static login leaked to Auth2"); // Verify useful player information testContext.NotNull(PlayFabSettings.staticPlayer.PlayFabId); testContext.NotNull(PlayFabSettings.staticPlayer.EntityId); testContext.NotNull(PlayFabSettings.staticPlayer.EntityType); PlayFabClientAPI.ForgetAllCredentials(); testContext.EndTest(UUnitFinishState.PASSED, PlayFabSettings.staticSettings.TitleId + ", " + loginTask.Result.Result.PlayFabId); }
private void InvalidRegistrationContinued(PlayFabResult <RegisterPlayFabUserResult> registerResult, UUnitTestContext testContext, string failMessage) { testContext.NotNull(registerResult, failMessage); testContext.IsNull(registerResult.Result, failMessage); testContext.NotNull(registerResult.Error, failMessage); var expectedEmailMsg = "email address is not valid."; var expectedPasswordMsg = "password must be between"; var fullReport = registerResult.Error.GenerateErrorReport(); testContext.True(fullReport.ToLower().Contains(expectedEmailMsg), "Expected an error about bad email address: " + fullReport); testContext.True(fullReport.ToLower().Contains(expectedPasswordMsg), "Expected an error about bad password: " + fullReport); }
public void ArrayAsObject(UUnitTestContext testContext) { string json = "{\"Version\": \"2016-06-21_23-57-16\", \"ObjectArray\": [{\"Id\": 2, \"Name\": \"Stunned\", \"Type\": \"Condition\", \"ShowNumber\": true, \"EN_text\": \"Stunned\", \"EN_reminder\": \"Can\'t attack, block, or activate\"}, {\"Id\": 3, \"Name\": \"Poisoned\", \"Type\": \"Condition\", \"ShowNumber\": true, \"EN_text\": \"Poisoned\", \"EN_reminder\": \"Takes {N} damage at the start of each turn. Wears off over time.\" }], \"StringArray\": [\"NoSubtype\", \"Aircraft\"]}"; var result = JsonWrapper.DeserializeObject <Dictionary <string, object> >(json); var version = result["Version"] as string; var objArray = result["ObjectArray"] as List <object>; var strArray = result["StringArray"] as List <object>; testContext.NotNull(result); testContext.True(!string.IsNullOrEmpty(version)); testContext.True(objArray != null && objArray.Count > 0); testContext.True(strArray != null && strArray.Count > 0); testContext.EndTest(UUnitFinishState.PASSED, null); }
private void LoginWithAdvertisingIdContinued(PlayFabResult <LoginResult> loginResult, UUnitTestContext testContext, string failMessage) { PlayFabId = loginResult.Result.PlayFabId; // Needed for subsequent tests testContext.True(PlayFabClientAPI.IsClientLoggedIn(), "User login failed"); testContext.StringEquals(PlayFabSettings.AD_TYPE_ANDROID_ID + "_Successful", PlayFabSettings.AdvertisingIdType); }
private void InvalidLoginContinued(PlayFabResult <LoginResult> loginResult, UUnitTestContext testContext, string failMessage) { testContext.NotNull(loginResult, failMessage); testContext.IsNull(loginResult.Result, failMessage); testContext.NotNull(loginResult.Error, failMessage); testContext.True(loginResult.Error.ErrorMessage.Contains("password"), loginResult.Error.ErrorMessage); }
private void InvalidLoginContinued(PlayFabResult <LoginResult> loginResult, UUnitTestContext testContext, string failMessage) { testContext.NotNull(loginResult, failMessage); testContext.IsNull(loginResult.Result, failMessage); testContext.NotNull(loginResult.Error, failMessage); testContext.True(loginResult.Error.ErrorMessage.Contains("password"), loginResult.Error.ErrorMessage + ", for: " + testTitleData.userEmail + ", on: " + PlayFabSettings.staticSettings.TitleId); }
public void ObjectApi(UUnitTestContext testContext) { testContext.True(dataApi.IsEntityLoggedIn(), "Client"); var getRequest = new DataModels.GetObjectsRequest { Entity = new DataModels.EntityKey { Id = clientApi.authenticationContext.EntityId, Type = clientApi.authenticationContext.EntityType }, EscapeObject = true }; dataApi.GetObjects(getRequest, PlayFabUUnitUtils.ApiActionWrapper <DataModels.GetObjectsResponse>(testContext, GetObjectCallback1), PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext); }
void TestFileContent(UUnitTestContext testContext, byte[] result) { var json = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer); testContext.NotNull(result, "Raw file result was null"); testContext.True(result.Length > 0, "Raw file result was zero length"); testContext.StringEquals(json.SerializeObject(_testPayload), json.SerializeObject(result), json.SerializeObject(result)); DeleteFiles(testContext, new List <string> { TEST_FILE_NAME }, true, UUnitFinishState.PASSED, "File " + TEST_FILE_NAME + " was succesfully created and uploaded to server with PUT"); }
public void AsyncMultiUserApiCall(UUnitTestContext testContext) { var player1Request = new GetAccountInfoRequest { AuthenticationContext = _player1 }; var player2Request = new GetAccountInfoRequest { AuthenticationContext = _player2 }; UserAccountInfo player1AccountInfo = null; UserAccountInfo player2AccountInfo = null; PlayFabClientAPI.GetAccountInfo(player1Request, x => player1AccountInfo = x.AccountInfo, PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext); PlayFabClientAPI.GetAccountInfo(player2Request, x => player2AccountInfo = x.AccountInfo, PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext); _tickAction = () => { // wait loading account info if (player1AccountInfo == null || player2AccountInfo == null) { return; } // reset delegate to avoid calling this method again _tickAction = null; // compares received data with cached data to make sure everything works correctly testContext.True(_player1.PlayFabId == player1AccountInfo.PlayFabId, "Player1 PlayFabIds not match!"); testContext.True(_player2.PlayFabId == player2AccountInfo.PlayFabId, "Player2 PlayFabIds not match!"); // playFabId at different players must be different testContext.False(player1AccountInfo.PlayFabId == player2AccountInfo.PlayFabId, "Players PlayFabId is equals!"); testContext.EndTest(UUnitFinishState.PASSED, _player1.PlayFabId + ", " + _player2.PlayFabId); }; }
private void UserDataApiContinued3(PlayFabResult <GetUserDataResult> getDataResult2, UUnitTestContext testContext, string failMessage) { int testCounterValueActual; UserDataRecord testCounter; getDataResult2.Result.Data.TryGetValue(TEST_DATA_KEY, out testCounter); testContext.NotNull(testCounter, "The updated UserData was not found in the Api results"); int.TryParse(testCounter.Value, out testCounterValueActual); testContext.IntEquals(_testInteger, testCounterValueActual); var timeUpdated = testCounter.LastUpdated; var testMin = DateTime.UtcNow - TimeSpan.FromMinutes(5); var testMax = testMin + TimeSpan.FromMinutes(10); testContext.True(testMin <= timeUpdated && timeUpdated <= testMax); }
public void JsonPropertyTest(UUnitTestContext testContext) { var expectedObject = new JsonPropertyAttrTestClass { InvalidField = "asdf", InvalidProperty = "fdsa" }; string json = JsonWrapper.SerializeObject(expectedObject); // Verify that the field names have been transformed by the JsonProperty attribute testContext.False(json.ToLower().Contains("invalid"), json); testContext.False(json.ToLower().Contains("hidenull"), json); testContext.True(json.ToLower().Contains("shownull"), json); // Verify that the fields are re-serialized into the proper locations by the JsonProperty attribute var actualObject = JsonWrapper.DeserializeObject <JsonPropertyAttrTestClass>(json); testContext.StringEquals(expectedObject.InvalidField, actualObject.InvalidField, actualObject.InvalidField); testContext.StringEquals(expectedObject.InvalidProperty, actualObject.InvalidProperty, actualObject.InvalidProperty); testContext.EndTest(UUnitFinishState.PASSED, null); }
public void PluginManagerCustomPlugin(UUnitTestContext testContext) { var playFabSerializer = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer); var expectedSerializer = new CustomSerializerPlugin(); try { // Set a custom serializer plugin PluginManager.SetPlugin(expectedSerializer, PluginContract.PlayFab_Serializer); // Get serializer plugin from manager var actualSerializer = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer); // Verify testContext.True(object.ReferenceEquals(actualSerializer, expectedSerializer)); testContext.EndTest(UUnitFinishState.PASSED, null); } finally { // Restore the original plugin PluginManager.SetPlugin(playFabSerializer, PluginContract.PlayFab_Serializer); } }
private void LeaderBoardContinued(PlayFabResult <GetAccountInfoResult> accountResult, UUnitTestContext testContext, string failMessage) { testContext.True(Enum.IsDefined(typeof(UserOrigination), accountResult.Result.AccountInfo.TitleInfo.Origination.Value), "Origination Enum not valid"); }
private static void CheckCallbacks(UUnitTestContext testContext, string expected, HashSet <string> actual) { testContext.True(actual.Contains(expected), "Want: " + expected + ", Got: " + string.Join(", ", actual.ToArray())); }
private void LoginOrRegisterContinued(PlayFabResult <LoginResult> loginResult, UUnitTestContext testContext, string failMessage) { PlayFabId = loginResult.Result.PlayFabId; // Needed for subsequent tests testContext.True(PlayFabClientAPI.IsClientLoggedIn(), "User login failed"); }
private void LeaderBoardContinued(PlayFabResult <GetLeaderboardResult> clientResult, UUnitTestContext testContext, string failMessage) { testContext.True(clientResult.Result.Leaderboard.Count > 0, "Leaderboard does not contain enough entries."); }
private void LoginWithAdvertisingIdContinued(PlayFabResult <LoginResult> loginResult, UUnitTestContext testContext, string failMessage) { testContext.True(clientApi.IsClientLoggedIn(), failMessage); testContext.StringEquals(PlayFabSettings.AD_TYPE_ANDROID_ID + "_Successful", PlayFabSettings.staticSettings.AdvertisingIdType); }
private void LoginOrRegisterContinued(PlayFabResult <LoginResult> loginResult, UUnitTestContext testContext, string failMessage) { testContext.True(clientApi.IsClientLoggedIn(), failMessage); }