public void AuthenticateWithInvalidPasswordOnUserService() { //arrange var mockUserRepository = new Mock<IUserRepository>(); mockUserRepository.Setup(x => x.GetAll()).Returns(_users); UserService userService = new UserService(mockUserRepository.Object); //act User retUser = userService.Authenticate(_user.Username, _user.Password + "WRONG"); //assert - expect exception userService.Dispose(); }
public void AuthenticateWithNoExistentUserOnUserService() { //arrange var mockUserRepository = new Mock<IUserRepository>(); mockUserRepository.Setup(x => x.GetAll()).Returns(_users); UserService userService = new UserService(mockUserRepository.Object); //act User retUser = userService.Authenticate(_user.Username + "DOESNTEXIST", _user.Password); //assert - expect exception userService.Dispose(); }
public void AuthenticateValidPasswordOnUserService() { //arrange var mockUserRepository = new Mock<IUserRepository>(); mockUserRepository.Setup(x => x.GetAll()).Returns(_users); UserService userService = new UserService(mockUserRepository.Object); //act User retUser = userService.Authenticate(_user.Username, _user.Password); //assert Assert.AreEqual(_user, retUser); userService.Dispose(); }