예제 #1
0
            public void SetsUnconfirmedEmailWhenEmailIsChanged()
            {
                var user    = CreateUser("Bob", "ThePassword", "*****@*****.**");
                var service = new TestableUserServiceWithDBFaking
                {
                    Users = new[] { user }
                };

                service.ChangeEmailAddress(user, "*****@*****.**");

                Assert.Equal("*****@*****.**", user.EmailAddress);
                Assert.Equal("*****@*****.**", user.UnconfirmedEmailAddress);
                service.FakeEntitiesContext.VerifyCommitChanges();
            }
예제 #2
0
            public void DoesNotModifyConfirmationTokenWhenUnconfirmedEmailAddressNotChanged(string confirmedEmailAddress)
            {
                var user = new User {
                    EmailAddress            = confirmedEmailAddress,
                    UnconfirmedEmailAddress = "*****@*****.**",
                    EmailConfirmationToken  = "pending-token"
                };
                var service = new TestableUserServiceWithDBFaking
                {
                    Users = new User[] { user },
                };

                service.ChangeEmailAddress(user, "*****@*****.**");
                Assert.Equal("pending-token", user.EmailConfirmationToken);
            }
예제 #3
0
            public void DoesNotModifyAnythingWhenConfirmedEmailAddressNotChanged()
            {
                var user = new User {
                    EmailAddress = "*****@*****.**", UnconfirmedEmailAddress = null, EmailConfirmationToken = null
                };
                var service = new TestableUserServiceWithDBFaking
                {
                    Users = new User[] { user },
                };

                service.ChangeEmailAddress(user, "*****@*****.**");
                Assert.True(user.Confirmed);
                Assert.Equal("*****@*****.**", user.EmailAddress);
                Assert.Null(user.UnconfirmedEmailAddress);
                Assert.Null(user.EmailConfirmationToken);
            }
예제 #4
0
            public void ModifiesConfirmationTokenWhenEmailAddressChanged()
            {
                var user = new User {
                    EmailAddress = "*****@*****.**", EmailConfirmationToken = "pending-token"
                };
                var service = new TestableUserServiceWithDBFaking
                {
                    Users = new User[] { user },
                };

                service.ChangeEmailAddress(user, "*****@*****.**");
                Assert.NotNull(user.EmailConfirmationToken);
                Assert.NotEmpty(user.EmailConfirmationToken);
                Assert.NotEqual("pending-token", user.EmailConfirmationToken);
                service.FakeEntitiesContext.VerifyCommitChanges();
            }
예제 #5
0
            public async Task SetsUnconfirmedEmailWhenEmailIsChanged()
            {
                var user = new User {
                    Username = "******", EmailAddress = "*****@*****.**"
                };
                var service = new TestableUserServiceWithDBFaking
                {
                    Users = new[] { user }
                };

                await service.ChangeEmailAddress(user, "*****@*****.**");

                Assert.Equal("*****@*****.**", user.EmailAddress);
                Assert.Equal("*****@*****.**", user.UnconfirmedEmailAddress);
                service.FakeEntitiesContext.VerifyCommitChanges();
            }
예제 #6
0
            public void DoesNotLetYouUseSomeoneElsesConfirmedEmailAddress()
            {
                var user = new User {
                    EmailAddress = "*****@*****.**", Key = 1
                };
                var conflictingUser = new User {
                    EmailAddress = "*****@*****.**", Key = 2
                };
                var service = new TestableUserServiceWithDBFaking
                {
                    Users = new User[] { user, conflictingUser },
                };

                var e = Assert.Throws <EntityException>(() => service.ChangeEmailAddress(user, "*****@*****.**"));

                Assert.Equal(string.Format(Strings.EmailAddressBeingUsed, "*****@*****.**"), e.Message);
                Assert.Equal("*****@*****.**", user.EmailAddress);
            }
예제 #7
0
            public async Task WritesAuditRecord()
            {
                // Arrange
                var user = new User {
                    Username = "******", EmailAddress = "*****@*****.**"
                };
                var service = new TestableUserServiceWithDBFaking
                {
                    Users = new[] { user }
                };

                // Act
                await service.ChangeEmailAddress(user, "*****@*****.**");

                // Assert
                Assert.True(service.Auditing.WroteRecord <UserAuditRecord>(ar =>
                                                                           ar.Action == AuditedUserAction.ChangeEmail &&
                                                                           ar.AffectedEmailAddress == "*****@*****.**" &&
                                                                           ar.EmailAddress == "*****@*****.**"));
            }
예제 #8
0
            public async Task WritesAuditRecord()
            {
                // Arrange
                var user = new User { Username = "******", EmailAddress = "*****@*****.**" };
                var service = new TestableUserServiceWithDBFaking
                {
                    Users = new[] { user }
                };

                // Act
                await service.ChangeEmailAddress(user, "*****@*****.**");

                // Assert
                Assert.True(service.Auditing.WroteRecord<UserAuditRecord>(ar =>
                    ar.Action == AuditedUserAction.ChangeEmail &&
                    ar.AffectedEmailAddress == "*****@*****.**" &&
                    ar.EmailAddress == "*****@*****.**"));
            }
예제 #9
0
            public async Task DoesNotLetYouUseSomeoneElsesConfirmedEmailAddress()
            {
                var user = new User { EmailAddress = "*****@*****.**", Key = 1 };
                var conflictingUser = new User { EmailAddress = "*****@*****.**", Key = 2 };
                var service = new TestableUserServiceWithDBFaking
                {
                    Users = new User[] { user, conflictingUser },
                };

                var e = await AssertEx.Throws<EntityException>(() => service.ChangeEmailAddress(user, "*****@*****.**"));
                Assert.Equal(string.Format(Strings.EmailAddressBeingUsed, "*****@*****.**"), e.Message);
                Assert.Equal("*****@*****.**", user.EmailAddress);
            }
예제 #10
0
            public async Task DoesNotModifyConfirmationTokenWhenUnconfirmedEmailAddressNotChanged(string confirmedEmailAddress)
            {
                var user = new User {
                    EmailAddress = confirmedEmailAddress,
                    UnconfirmedEmailAddress = "*****@*****.**",
                    EmailConfirmationToken = "pending-token" };
                var service = new TestableUserServiceWithDBFaking
                {
                    Users = new User[] { user },
                };

                await service.ChangeEmailAddress(user, "*****@*****.**");
                Assert.Equal("pending-token", user.EmailConfirmationToken);
            }
예제 #11
0
            public async Task DoesNotModifyAnythingWhenConfirmedEmailAddressNotChanged()
            {
                var user = new User { EmailAddress = "*****@*****.**", UnconfirmedEmailAddress = null, EmailConfirmationToken = null };
                var service = new TestableUserServiceWithDBFaking
                {
                    Users = new User[] { user },
                };

                await service.ChangeEmailAddress(user, "*****@*****.**");
                Assert.True(user.Confirmed);
                Assert.Equal("*****@*****.**", user.EmailAddress);
                Assert.Null(user.UnconfirmedEmailAddress);
                Assert.Null(user.EmailConfirmationToken);
            }
예제 #12
0
            public async Task ModifiesConfirmationTokenWhenEmailAddressChanged()
            {
                var user = new User { EmailAddress = "*****@*****.**", EmailConfirmationToken = "pending-token" };
                var service = new TestableUserServiceWithDBFaking
                {
                    Users = new User[] { user },
                };

                await service.ChangeEmailAddress(user, "*****@*****.**");
                Assert.NotNull(user.EmailConfirmationToken);
                Assert.NotEmpty(user.EmailConfirmationToken);
                Assert.NotEqual("pending-token", user.EmailConfirmationToken);
                service.FakeEntitiesContext.VerifyCommitChanges();
            }
예제 #13
0
            public async Task SetsUnconfirmedEmailWhenEmailIsChanged()
            {
                var user = new User { Username = "******", EmailAddress = "*****@*****.**" };
                var service = new TestableUserServiceWithDBFaking
                {
                    Users = new[] { user }
                };

                await service.ChangeEmailAddress(user, "*****@*****.**");

                Assert.Equal("*****@*****.**", user.EmailAddress);
                Assert.Equal("*****@*****.**", user.UnconfirmedEmailAddress);
                service.FakeEntitiesContext.VerifyCommitChanges();
            }
예제 #14
0
            public void SetsUnconfirmedEmailWhenEmailIsChanged()
            {
                var user = CreateUser("Bob", "ThePassword", "*****@*****.**");
                var service = new TestableUserServiceWithDBFaking
                {
                    Users = new[] { user }
                };

                service.ChangeEmailAddress(user, "*****@*****.**");

                Assert.Equal("*****@*****.**", user.EmailAddress);
                Assert.Equal("*****@*****.**", user.UnconfirmedEmailAddress);
                service.FakeEntitiesContext.VerifyCommitChanges();
            }