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

                    Assert.Equal("This email is already associated with this account.",
                                 helper.UserAlreadyOwnsEmail.Message);
                }
Ejemplo 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);
                }
Ejemplo 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);
                }
Ejemplo 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);
                }
Ejemplo 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);
                }
Ejemplo 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);
                }
Ejemplo n.º 7
0
                public async Task NullUser_Throws()
                {
                    var helper = new FakeUserHelper1();

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

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

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

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

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

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

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

                    Assert.True(helper.FakeUserEmailStore.Retrieve_Called);
                }
Ejemplo 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);
                }
Ejemplo n.º 14
0
                public async Task InvalidCode_ReturnsFalse()
                {
                    var helper = new FakeUserHelper1();

                    helper.FakeSingleUseTokenService.Validate_Output = false;

                    Assert.False(await helper.ValidatePasswordResetCode("key", 1234));
                }
Ejemplo 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);
                }
Ejemplo 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);
                }
Ejemplo n.º 18
0
                public async Task WhiteSpaceKey_Throws()
                {
                    UserHelper helper = new FakeUserHelper1();

                    await Assert.ThrowsAsync <ArgumentException>("key", async() =>
                    {
                        await helper.IsLockedOut(key: " ");
                    });
                }
Ejemplo 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);
                }
Ejemplo 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"));
                    });
Ejemplo 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);
                }
Ejemplo 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 !);
                    });
Ejemplo 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: "*****@*****.**");
                    });
Ejemplo 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);
                    });
Ejemplo 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);
                }
Ejemplo 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);
                }
Ejemplo 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);
                }
Ejemplo 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);
                }
Ejemplo 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);
                }
Ejemplo 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);
                }