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 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);
        }
        public void AsyncMultiUserLogin(UUnitTestContext testContext)
        {
            var player1LoginRequest = new LoginWithCustomIDRequest
            {
                CustomId      = PlayFabSettings.BuildIdentifier + "0",
                CreateAccount = true
            };

            var player2LoginRequest = new LoginWithCustomIDRequest
            {
                CustomId      = PlayFabSettings.BuildIdentifier + "1",
                CreateAccount = true
            };

            PlayFabClientAPI.LoginWithCustomID(player1LoginRequest, x => _player1 = x.AuthenticationContext,
                                               PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext);
            PlayFabClientAPI.LoginWithCustomID(player2LoginRequest, x => _player2 = x.AuthenticationContext,
                                               PlayFabUUnitUtils.ApiActionWrapper <PlayFabError>(testContext, SharedErrorCallback), testContext);

            _tickAction = () =>
            {
                // return if players not loaded yet
                if (_player1 == null || _player2 == null)
                {
                    return;
                }

                // reset delegate to avoid calling this method again
                _tickAction = null;

                // players must not be equals
                testContext.False(_player1.PlayFabId == _player2.PlayFabId);
                testContext.EndTest(UUnitFinishState.PASSED, "Two players are successfully login. " + _player1.PlayFabId + ", " + _player2.PlayFabId);
            };
        }
Exemple #4
0
 private void ProcessBothLogins(UUnitTestContext testContext)
 {
     testContext.False(InstancePlayFabId1 == InstancePlayFabId2);
     if (!string.IsNullOrEmpty(InstancePlayFabId1) && !string.IsNullOrEmpty(InstancePlayFabId2))
     {
         testContext.EndTest(UUnitFinishState.PASSED, null);
     }
 }
Exemple #5
0
        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);
        }
 private void VerifyCleanCreds(UUnitTestContext testContext)
 {
     testContext.False(client1.IsClientLoggedIn(), "Client1 login did not clean up properly.");
     testContext.False(client2.IsClientLoggedIn(), "Client2 login did not clean up properly.");
     testContext.False(auth1.IsEntityLoggedIn(), "Entity1 login did not clean up properly.");
     testContext.False(auth2.IsEntityLoggedIn(), "Entity2 login did not clean up properly.");
     testContext.False(PlayFabClientAPI.IsClientLoggedIn(), "Static client login did not clean up properly.");
     testContext.False(PlayFabAuthenticationAPI.IsEntityLoggedIn(), "Static entity login did not clean up properly.");
 }
Exemple #7
0
        //[UUnitTest]
        public void TestJsonSubObject(UUnitTestContext testContext)
        {
            // actualObj contains a real ObjNumFieldTest within subObject
            var expectedObj = new SerializeJsonSubOjbect {
                SubObject = new ObjNumFieldTest {
                    ByteValue = 1, DoubleValue = 1, FloatValue = 1, IntValue = 1, LongValue = 1, SbyteValue = 1, ShortValue = 1, UintValue = 1, UlongValue = 1, UshortValue = 1
                }
            };
            var expectedJson = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).SerializeObject(expectedObj);
            // Convert back to SerializeJsonSubOjbect which will serialize the original ObjNumFieldTest to a SimpleJson.JsonObject (or equivalent in another serializer)
            var actualObj = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).DeserializeObject <SerializeJsonSubOjbect>(expectedJson);

            testContext.False(actualObj.SubObject is ObjNumFieldTest, "ObjNumFieldTest should have deserialized as a generic JsonObject");
            var actualJson = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).SerializeObject(actualObj);

            // The real test is that reserializing actualObj should produce identical json
            testContext.StringEquals(expectedJson, actualJson, actualJson);

            testContext.EndTest(UUnitFinishState.PASSED, null);
        }
        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);
            };
        }