public AuthenticatedUserDTO AuthenticateUser(AuthenticationRequestDTO authenticationRequest) { GuardAgainst.ArgumentNull(authenticationRequest, "authenticationRequest"); var user = userRepository.FindOne(new UserByUsernameAndPassword(authenticationRequest.Username, encryptionService.Encrypt(authenticationRequest.Password))); return Mapper.Map<MembraneUser, AuthenticatedUserDTO>(user); }
public void CanReturnAuthenicatedUser() { var authenticationRequest = new AuthenticationRequestDTO { Username = "******", Password = "******" }; var result = new AuthenticatedUserDTO(); With.Mocks(mockery) .Expecting(() => Expect.Call(userRepository.FindOne(new UserByUsernameAndPassword(authenticationRequest.Username, authenticationRequest.Password))).IgnoreArguments().Return(new MembraneUser { Id = Guid.NewGuid(), Username = "******", Password = "******", Type = new MembraneUserType { Id = Guid.NewGuid(), Type = UserType.Administrator }})) .Verify(() => result = service.AuthenticateUser(authenticationRequest)); Assert.AreEqual(UserType.Administrator, result.Type); }