Exemplo n.º 1
0
                public void WhenCalled_ReturnsExpectedMessage()
                {
                    UserHelper helper = new FakeUserHelper1();

                    Assert.Equal("This email is already associated with this account.",
                                 helper.UserAlreadyOwnsEmail.Message);
                }
Exemplo n.º 2
0
                public void WhenCalled_ReturnsExpectedMessage()
                {
                    UserHelper helper = new FakeUserHelper1();

                    Assert.Equal("This account has been locked to protect it from possible hacking. Wait a few minutes to try again.",
                                 helper.LockedOut.Message);
                }
Exemplo n.º 3
0
                public void WhenCalled_ReturnsExpectedMessage()
                {
                    UserHelper helper = new FakeUserHelper1();

                    Assert.Equal("Those credentials weren't right. Go ahead and try again.",
                                 helper.InvalidCredentials.Message);
                }
Exemplo n.º 4
0
                public void WhenCalled_ReturnsExpectedMessage()
                {
                    UserHelper helper = new FakeUserHelper1();

                    Assert.Equal("We couldn't confirm your email. The link we sent you may have expired. You'll need to try confirming your email again.",
                                 helper.InvalidEmailVerificationCode.Message);
                }
Exemplo n.º 5
0
                public void WhenCalled_ReturnsExpectedMessage()
                {
                    UserHelper helper = new FakeUserHelper1();

                    Assert.Equal("That password reset code wasn't right. It may have expired.",
                                 helper.InvalidPasswordResetCode.Message);
                }
Exemplo n.º 6
0
                public void WhenCalled_ReturnsExpectedMessage()
                {
                    UserHelper helper = new FakeUserHelper1();

                    Assert.Equal("This email is not available. Is there a different one you can use?",
                                 helper.EmailNotAvailable.Message);
                }
Exemplo n.º 7
0
                public async Task NullUser_Throws()
                {
                    var helper = new FakeUserHelper1();

                    await Assert.ThrowsAsync <ArgumentNullException>("user", async() =>
                    {
                        await helper.SetCreated <User>(user: null !);
                    });
Exemplo n.º 8
0
                public async Task NullKey_Throws()
                {
                    UserHelper helper = new FakeUserHelper1();

                    await Assert.ThrowsAsync <ArgumentNullException>("key", async() =>
                    {
                        await helper.IsLockedOut(key: null !);
                    });
Exemplo n.º 9
0
                public async Task NullUser_Throws()
                {
                    UserHelper helper = new FakeUserHelper1();

                    await Assert.ThrowsAsync <ArgumentNullException>("user", async() =>
                    {
                        await helper.RefreshSecurityStamp <User>(user: null !);
                    });
Exemplo n.º 10
0
                public async Task NullEmail_Throws()
                {
                    UserHelper helper = new FakeUserHelper1();

                    await Assert.ThrowsAsync <ArgumentNullException>("email", async() =>
                    {
                        await helper.Retrieve <User>(email: null !);
                    });
Exemplo n.º 11
0
                public async Task KeyDoesNotExist_CallsRetrieveOnLockoutStore()
                {
                    var helper = new FakeUserHelper1();

                    _ = await helper.IsLockedOut("key");

                    Assert.Equal("key", helper.FakeTimedLockoutStore.Retrieve_KeyInput);
                }
Exemplo n.º 12
0
                public async Task WhenCalled_CallsUserEmailStore()
                {
                    var helper = new FakeUserHelper1();

                    await helper.Retrieve <User>(email : "*****@*****.**");

                    Assert.True(helper.FakeUserEmailStore.Retrieve_Called);
                }
Exemplo n.º 13
0
                public async Task UserEmailStoreReturnsUser_ReturnsUser()
                {
                    var helper = new FakeUserHelper1();

                    var user = await helper.Retrieve <User>("*****@*****.**");

                    Assert.Equal(helper.FakeUserEmailStore.Retrieve_Output, user);
                }
Exemplo n.º 14
0
                public async Task InvalidCode_ReturnsFalse()
                {
                    var helper = new FakeUserHelper1();

                    helper.FakeSingleUseTokenService.Validate_Output = false;

                    Assert.False(await helper.ValidatePasswordResetCode("key", 1234));
                }
Exemplo n.º 15
0
                public async Task WhenCalled_ReturnsVerificationCode()
                {
                    var helper  = new FakeUserHelper1();
                    var userKey = new UserKey("1");

                    var token = await helper.CreateEmailVerificationCode(userKey);

                    Assert.NotNull(token);
                }
                public async Task WhenCalled_SetsLastLogin()
                {
                    var helper = new FakeUserHelper1();
                    var user   = new User();

                    await helper.SetLastLogin(user);

                    Assert.Equal(helper.FakeClock.UtcNow.ToOffset(), user.LastLogin);
                }
Exemplo n.º 17
0
                public async Task WhenCalled_SetsCreated()
                {
                    var helper = new FakeUserHelper1();
                    var user   = new User();

                    await helper.SetCreated(user);

                    Assert.Equal(helper.FakeClock.UtcNow, user.Created);
                }
Exemplo n.º 18
0
                public async Task WhiteSpaceKey_Throws()
                {
                    UserHelper helper = new FakeUserHelper1();

                    await Assert.ThrowsAsync <ArgumentException>("key", async() =>
                    {
                        await helper.IsLockedOut(key: " ");
                    });
                }
Exemplo n.º 19
0
                public async Task ValidPassword_ReturnsSuccess()
                {
                    var helper = new FakeUserHelper1();

                    var result = await helper.SetPasswordHash(
                        new User(),
                        new Password("ValidPassword"));

                    Assert.True(result.Success);
                }
Exemplo n.º 20
0
                public async Task NullUser_Throws()
                {
                    UserHelper helper = new FakeUserHelper1();

                    await Assert.ThrowsAsync <ArgumentNullException>("user", async() =>
                    {
                        await helper.SetPasswordHash <User>(
                            user: null !,
                            password: new Password("ValidPassword"));
                    });
Exemplo n.º 21
0
                public async Task UserEmailStoreReturnsNull_ReturnsNull()
                {
                    var helper = new FakeUserHelper1();

                    helper.FakeUserEmailStore.Retrieve_Output = null;

                    var user = await helper.Retrieve <User>("*****@*****.**");

                    Assert.Null(user);
                }
Exemplo n.º 22
0
                public async Task NullPassword_Throws()
                {
                    UserHelper helper = new FakeUserHelper1();

                    await Assert.ThrowsAsync <ArgumentNullException>("password", async() =>
                    {
                        await helper.SetPasswordHash(
                            user: new User(),
                            password: null !);
                    });
Exemplo n.º 23
0
                public async Task NullUser_Throws()
                {
                    UserHelper helper = new FakeUserHelper1();

                    await Assert.ThrowsAsync <ArgumentNullException>("user", async() =>
                    {
                        await helper.SetEmail(
                            user: (User)null !,
                            email: "*****@*****.**");
                    });
Exemplo n.º 24
0
                public async Task NullUserKey_Throws()
                {
                    UserHelper helper = new FakeUserHelper1();

                    await Assert.ThrowsAsync <ArgumentNullException>("userKey", async() =>
                    {
                        await helper.ValidateEmailVerificationCode(
                            userKey: null !,
                            code: 1234);
                    });
Exemplo n.º 25
0
                public async Task WhenCalled_SetsExpirationTo7Days()
                {
                    var helper  = new FakeUserHelper1();
                    var userKey = new UserKey("1");

                    var code = await helper.CreateEmailVerificationCode(userKey);

                    Assert.Equal(helper.FakeClock.UtcNow.AddDays(7),
                                 helper.FakeSingleUseTokenService.Create_InputExpiration);
                }
Exemplo n.º 26
0
                public async Task ValidUser_SetsSecurityStamp20CharactersLong()
                {
                    UserHelper helper = new FakeUserHelper1();
                    var        user   = new User();

                    await helper.RefreshSecurityStamp(user);

                    Assert.NotNull(user.SecurityStamp);
                    Assert.Equal(20, user.SecurityStamp.Length);
                }
Exemplo n.º 27
0
                public async Task ValidUserKey_SetsExpirationTo1Day()
                {
                    var helper  = new FakeUserHelper1();
                    var userKey = new UserKey("key");

                    var code = await helper.CreatePasswordResetCode(userKey);

                    Assert.Equal(helper.FakeClock.UtcNow.AddDays(1),
                                 helper.FakeSingleUseTokenService.Create_InputExpiration);
                }
Exemplo n.º 28
0
                public async Task KeyDoesNotExist_ReturnsFalse()
                {
                    var helper = new FakeUserHelper1();

                    helper.FakeTimedLockoutStore.Retrieve_Output = null;

                    var result = await helper.IsLockedOut("key");

                    Assert.False(result);
                }
Exemplo n.º 29
0
                public async Task WhenCalled_ReturnsTrue()
                {
                    var helper = new FakeUserHelper1();

                    helper.FakeSingleUseTokenService.Validate_Output = true;

                    var result = await helper.ValidateEmailVerificationCode(
                        new UserKey("1"), 1111);

                    Assert.True(result);
                }
Exemplo n.º 30
0
                public async Task InvalidToken_ReturnsFalse()
                {
                    var helper = new FakeUserHelper1();

                    helper.FakeSingleUseTokenService.Validate_Output = false;

                    var result = await helper.ValidateEmailVerificationCode(
                        new UserKey("1"), 1111);

                    Assert.False(result);
                }