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(); }
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); }
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); }
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(); }
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(); }
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); }
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 == "*****@*****.**")); }
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 == "*****@*****.**")); }
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); }
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); }
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); }
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(); }