public async Task WithTokenThatDoesNotMatchUserReturnsFalse()
            {
                var user = new User { Username = "******", EmailConfirmationToken = "token" };
                var service = new TestableUserService();

                var confirmed = await service.ConfirmEmailAddress(user, "not-token");

                Assert.False(confirmed);
            }
Esempio n. 2
0
            public void WithTokenThatDoesNotMatchUserReturnsFalse()
            {
                var user = new User {
                    Username = "******", EmailConfirmationToken = "token"
                };
                var service = new TestableUserService();

                var confirmed = service.ConfirmEmailAddress(user, "not-token");

                Assert.False(confirmed);
            }
Esempio n. 3
0
            public async Task WritesAuditRecord()
            {
                var user = new User
                {
                    Username = "******",
                    EmailConfirmationToken  = "secret",
                    EmailAddress            = "*****@*****.**",
                    UnconfirmedEmailAddress = "*****@*****.**"
                };
                var service = new TestableUserService();

                var confirmed = await service.ConfirmEmailAddress(user, "secret");

                Assert.True(service.Auditing.WroteRecord <UserAuditRecord>(ar =>
                                                                           ar.Action == AuditedUserAction.ConfirmEmail &&
                                                                           ar.AffectedEmailAddress == "*****@*****.**"));
            }
Esempio n. 4
0
            public void WithTokenThatDoesMatchUserConfirmsUserAndReturnsTrue()
            {
                var user = new User
                {
                    Username = "******",
                    EmailConfirmationToken  = "secret",
                    UnconfirmedEmailAddress = "*****@*****.**"
                };
                var service = new TestableUserService();

                var confirmed = service.ConfirmEmailAddress(user, "secret");

                Assert.True(confirmed);
                Assert.True(user.Confirmed);
                Assert.Equal("*****@*****.**", user.EmailAddress);
                Assert.Null(user.UnconfirmedEmailAddress);
                Assert.Null(user.EmailConfirmationToken);
            }
Esempio n. 5
0
            public void WithEmptyTokenThrowsArgumentNullException()
            {
                var service = new TestableUserService();

                Assert.Throws <ArgumentNullException>(() => service.ConfirmEmailAddress(new User(), ""));
            }
Esempio n. 6
0
            public void WithNullUserThrowsArgumentNullException()
            {
                var service = new TestableUserService();

                Assert.Throws <ArgumentNullException>(() => service.ConfirmEmailAddress(null, "token"));
            }
            public async Task WithTokenThatDoesMatchUserConfirmsUserAndReturnsTrue()
            {
                var user = new User
                {
                    Username = "******",
                    EmailConfirmationToken = "secret",
                    UnconfirmedEmailAddress = "*****@*****.**"
                };
                var service = new TestableUserService();

                var confirmed = await service.ConfirmEmailAddress(user, "secret");

                Assert.True(confirmed);
                Assert.True(user.Confirmed);
                Assert.Equal("*****@*****.**", user.EmailAddress);
                Assert.Null(user.UnconfirmedEmailAddress);
                Assert.Null(user.EmailConfirmationToken);
            }
            public async Task WritesAuditRecord()
            {
                var user = new User
                {
                    Username = "******",
                    EmailConfirmationToken = "secret",
                    EmailAddress = "*****@*****.**",
                    UnconfirmedEmailAddress = "*****@*****.**"
                };
                var service = new TestableUserService();

                var confirmed = await service.ConfirmEmailAddress(user, "secret");

                Assert.True(service.Auditing.WroteRecord<UserAuditRecord>(ar =>
                    ar.Action == AuditedUserAction.ConfirmEmail &&
                    ar.AffectedEmailAddress == "*****@*****.**"));
            }
            public async Task WithEmptyTokenThrowsArgumentNullException()
            {
                var service = new TestableUserService();

                await AssertEx.Throws<ArgumentNullException>(() => service.ConfirmEmailAddress(new User(), ""));
            }
            public async Task WithNullUserThrowsArgumentNullException()
            {
                var service = new TestableUserService();

                await AssertEx.Throws<ArgumentNullException>(() => service.ConfirmEmailAddress(null, "token"));
            }
Esempio n. 11
0
            public async Task WithEmptyTokenThrowsArgumentNullException()
            {
                var service = new TestableUserService();

                await AssertEx.Throws <ArgumentNullException>(() => service.ConfirmEmailAddress(new User(), ""));
            }
Esempio n. 12
0
            public async Task WithNullUserThrowsArgumentNullException()
            {
                var service = new TestableUserService();

                await AssertEx.Throws <ArgumentNullException>(() => service.ConfirmEmailAddress(null, "token"));
            }
Esempio n. 13
0
            public void WithEmptyTokenThrowsArgumentNullException()
            {
                var service = new TestableUserService();

                Assert.Throws<ArgumentNullException>(() => service.ConfirmEmailAddress(new User(), ""));
            }
Esempio n. 14
0
            public void WithNullUserThrowsArgumentNullException()
            {
                var service = new TestableUserService();

                Assert.Throws<ArgumentNullException>(() => service.ConfirmEmailAddress(null, "token"));
            }