public void FindByEmail() { var mock = new Mock<IUserRepository>(); mock.Setup(x => x.GetAll()).Returns(new User[] { new User() { Email = "*****@*****.**"}, new User() { Email = "*****@*****.**"}, new User() { Email = "*****@*****.**"}, new User() { Email = "*****@*****.**"} }); var emailMock = new Mock<IEmailSender>(); var target = new UserService(mock.Object, emailMock.Object); var result = target.FindByEmail("*****@*****.**"); result.Email.Should().Be("*****@*****.**"); }
public void SendNewPasswordToEmail() { var mock = new Mock<IUserRepository>(); var emailMock = new Mock<IEmailSender>(); var target = new UserService(mock.Object, emailMock.Object); string oldPassword = "******"; var user = new User() { Email = "*****@*****.**", Password = oldPassword }; mock.Setup(x => x.GetAll()).Returns(new User[]{ user }); target.SendNewPasswordToEmail(user.Email); target.FindByEmail(user.Email).Password.Should().Not.Be(oldPassword); }