Пример #1
0
    public void EmailPasswordLoginSuccess(UUnitTestContext testContext)
    {
        const string email    = "*****@*****.**";
        const string password = "******";
        const string username = "******";

        _emailAuthService          = new PlayFabAuthService();
        _emailAuthService.Email    = email;
        _emailAuthService.Password = password;
        _emailAuthService.Username = username;

        _emailAuthService.OnLoginSuccess += (success) =>
        {
            testContext.True(!string.IsNullOrEmpty(success.PlayFabId));
            testContext.NotNull(_emailAuthService.IsClientLoggedIn());
            testContext.EndTest(UUnitFinishState.PASSED, "Email & password auth success. " + success.PlayFabId);
        };
        _emailAuthService.OnPlayFabError += (error) =>
        {
            testContext.Fail("Email & password auth failed with error: " + error.GenerateErrorReport());
        };
        _emailAuthService.OnDisplayAuthentication += () =>
        {
            testContext.Fail("Email & password auth failed.");
        };
        _emailAuthService.Authenticate(AuthTypes.EmailPassword);
    }
 private void WaitForExpectedMessages(UUnitTestContext testContext)
 {
     if (_expectedMessages.Count == 0 && _expectedCustom.Count == 0)
     {
         _messagesTested = true;
         testContext.EndTest(UUnitFinishState.PASSED, null);
     }
     if (DateTime.UtcNow > testContext.StartTime + TimeSpan.FromSeconds(TestExpire))
     {
         var sb = new StringBuilder();
         if (_expectedMessages.Count > 0)
         {
             sb.Append(_expectedMessages.Count).Append(" Missing Messages: ");
             foreach (var eachMsg in _expectedMessages)
             {
                 sb.Append(eachMsg).Append(",");
             }
             sb.Length -= 1;
         }
         if (_expectedCustom.Count > 0)
         {
             sb.Append(_expectedCustom.Count).Append("\nMissing Custom: ");
             foreach (var eachMsg in _expectedCustom)
             {
                 sb.Append(eachMsg).Append(",");
             }
             sb.Length -= 1;
         }
         testContext.Fail(sb.ToString());
     }
 }
Пример #3
0
    public void InvalidServiceSetup(UUnitTestContext testContext)
    {
        var authService = new PlayFabAuthService();

        authService.OnDisplayAuthentication += () => testContext.EndTest(UUnitFinishState.PASSED, "Invoke display as expected.");
        authService.OnLoginSuccess          += (success) => testContext.Fail("Invoke display expected.");
        authService.OnPlayFabError          += (error) => testContext.EndTest(UUnitFinishState.PASSED, "Error is not expected.");
        authService.Authenticate(AuthTypes.UsernamePassword);
    }
Пример #4
0
    public void InvalidEmailPasswordLogin(UUnitTestContext testContext)
    {
        const string password = "******";
        const string username = "******";
        const string email    = "LoginTest.com";

        var authService = new PlayFabAuthService();

        authService.Password = password;
        authService.Username = username;
        authService.Email    = email;

        authService.OnLoginSuccess          += (success) => testContext.Fail("Login fail expected.");
        authService.OnPlayFabError          += (error) => testContext.EndTest(UUnitFinishState.PASSED, "Error handle as expected.");
        authService.OnDisplayAuthentication += () => testContext.Fail("Failed with unknown error.");

        authService.Authenticate(AuthTypes.UsernamePassword);
    }
Пример #5
0
    public void TestSilentLoginAfterUnlink(UUnitTestContext testContext)
    {
        var silentAuth = new PlayFabAuthService();

        silentAuth.OnLoginSuccess += (success) =>
        {
            testContext.True(success.PlayFabId != _emailAuthService.AuthenticationContext.PlayFabId, "Silent auth and email auth playFabIds is match!");
            testContext.EndTest(UUnitFinishState.PASSED, "Silent auth completed as expected. New playFabId: " + success.PlayFabId);
        };
        silentAuth.OnPlayFabError += (error) =>
        {
            testContext.Fail("Silent auth abort with error: " + error.Error.ToString());
        };
        silentAuth.Authenticate(AuthTypes.Silent);
    }
Пример #6
0
    public void LoginWithDeviceId(UUnitTestContext testContext)
    {
        var silentAuth = new PlayFabAuthService();

        silentAuth.OnLoginSuccess += (success) =>
        {
            testContext.StringEquals(_emailAuthService.AuthenticationContext.PlayFabId, success.PlayFabId);
            testContext.EndTest(UUnitFinishState.PASSED, "Silent auth success with playFabId: " + success.PlayFabId);
        };
        silentAuth.OnPlayFabError += (error) =>
        {
            testContext.Fail("Silent auth failed with error: " + error.ErrorMessage);
        };
        silentAuth.Authenticate(AuthTypes.Silent);
    }
Пример #7
0
 public void TestUnLinkDeviceId(UUnitTestContext testContext)
 {
     _emailAuthService.OnPlayFabUnlink += (auth, error) =>
     {
         if (error == null)
         {
             testContext.EndTest(UUnitFinishState.PASSED, "UnLink deviceId success.");
         }
         else
         {
             testContext.Fail("UnLink deviceId failed with error: " + error.ErrorMessage);
         }
     };
     _emailAuthService.Unlink(new AuthKeys {
         AuthType = AuthTypes.Silent
     });
 }
Пример #8
0
 public void LinkDeviceToAccountSuccess(UUnitTestContext testContext)
 {
     _emailAuthService.ForceLink      = true;
     _emailAuthService.OnPlayFabLink += (auth, error) =>
     {
         if (error == null)
         {
             testContext.EndTest(UUnitFinishState.PASSED, "Link deviceId success.");
         }
         else
         {
             testContext.Fail("Link deviceId failed with error: " + error.GenerateErrorReport());
         }
     };
     _emailAuthService.Link(new AuthKeys {
         AuthType = AuthTypes.Silent
     });
 }
Пример #9
0
    public void InvalidUnlink(UUnitTestContext testContext)
    {
        var authService = new PlayFabAuthService();

        authService.OnPlayFabUnlink += (auth, error) =>
        {
            if (error != null)
            {
                testContext.EndTest(UUnitFinishState.PASSED, "Error handle as expected. " + error.GenerateErrorReport());
            }
            else
            {
                testContext.Fail("Error expected.");
            }
        };
        authService.Unlink(new AuthKeys {
            AuthType = AuthTypes.Facebook
        });
    }
Пример #10
0
    public void TestUnlinkedDeviceStatus(UUnitTestContext testContext)
    {
        PlayFabClientAPI.GetAccountInfo(new GetAccountInfoRequest
        {
            AuthenticationContext = _emailAuthService.AuthenticationContext
        }, response =>
        {
#if UNITY_ANDROID && !UNITY_EDITOR
            testContext.IsNull(response.AccountInfo.AndroidDeviceInfo, "Android deviceID should be null!");
#elif UNITY_IPHONE || UNITY_IOS && !UNITY_EDITOR
            testContext.IsNull(response.AccountInfo.IosDeviceInfo, "iOS deviceID should be null!");
#else
            testContext.IsNull(response.AccountInfo.CustomIdInfo, "customID should be null!");
#endif
            testContext.EndTest(UUnitFinishState.PASSED, "DeviceId successfully unlinked!");
        },
                                        (error) =>
        {
            testContext.Fail("GetAccountInfo error: " + error.ErrorMessage);
        });
    }
Пример #11
0
    public void TestLinkDeviceIdStatus(UUnitTestContext testContext)
    {
        PlayFabClientAPI.GetAccountInfo(new GetAccountInfoRequest
        {
            AuthenticationContext = _emailAuthService.AuthenticationContext
        }, response =>
        {
#if UNITY_ANDROID && !UNITY_EDITOR
            testContext.StringEquals(response.AccountInfo.AndroidDeviceInfo.AndroidDeviceId, PlayFabSettings.DeviceUniqueIdentifier, "Android deviceID not match!");
#elif UNITY_IPHONE || UNITY_IOS && !UNITY_EDITOR
            testContext.StringEquals(response.AccountInfo.IosDeviceInfo.IosDeviceId, PlayFabSettings.DeviceUniqueIdentifier, "iOS deviceID not match!");
#else
            testContext.StringEquals(response.AccountInfo.CustomIdInfo.CustomId, _emailAuthService.GetOrCreateRememberMeId(), "customId not match!");
#endif
            testContext.EndTest(UUnitFinishState.PASSED, "DeviceId successfully linked!");
        },
                                        (error) =>
        {
            testContext.Fail("GetAccountInfo error: " + error.ErrorMessage);
        });
    }
Пример #12
0
 /// <summary>
 /// During testing, this will be called every tick that a test is asynchronous.
 /// This is run every unity tick until testContext.EndTest() is called, or until the test times out.
 /// This is considered part of the active test. A failure or exception in this method will be considered a failure for the active test.
 /// </summary>
 public virtual void Tick(UUnitTestContext testContext)
 {
     testContext.Fail(GetType().Name + "." + testContext.Name + ": Async TestCase does not implement Tick().  To fix this error, implement \"" + GetType().Name + ".Tick()\" in your async test, or call testContext.EndTest() in your syncronous test.");
 }