public void user_cannot_login_with_invalid_email() { var user = new User { Email = "*****@*****.**", Password = "******", UserName = "******" }; var returnUser = new User { Email = "*****@*****.**", Password = "******", UserName = "******" }; userRepository.Setup(ur => ur.Save(user)); userRepository.Setup(ur => ur.GetUserByEmail(user.Email)).Returns(new User()); var membership = new domain.Services.Membership.MembershipService(userRepository.Object, new UserValidator(userRepository.Object)); membership.Register(user.Email, user.Password, user.Password, user.UserName); var serviceReply = membership.Login(user.Email, user.Password); serviceReply.Success.Should().BeFalse(); }
public void user_can_login() { var user = new User {Email = "*****@*****.**", Password = "******", UserName = "******"}; var returnUser = new User { Email = "*****@*****.**", Password = Password.Hash("password"), UserName = "******" }; userRepository.Setup(ur => ur.Save(user)); userRepository.Setup(ur => ur.GetUserByEmail(user.Email)).Returns(returnUser); var membership = new domain.Services.Membership.MembershipService(userRepository.Object, new UserValidator(userRepository.Object)); membership.Register(user.Email, user.Password, user.Password, user.UserName); var serviceReply = membership.Login(user.Email, user.Password); serviceReply.Result.UserName.Should().BeEquivalentTo(user.UserName); }
public void user_cannot_register_with_invalid_registration() { var membership = new domain.Services.Membership.MembershipService(userRepository.Object, new UserValidator(userRepository.Object)); var result = membership.Register("testtest.com", "pass", "password", "TestUser"); result.Success.Should().BeFalse(); result.FailureDetails.Should().NotBeEmpty(); }
public void user_can_register_with_valid_email_and_password() { var membership = new domain.Services.Membership.MembershipService(userRepository.Object, new UserValidator(userRepository.Object)); var result = membership.Register("*****@*****.**", "password", "password", "TestUser"); result.Success.Should().BeTrue(); }