public void GetByEmail_GetInvalidUser_ObjectNotFoundException() { // Arrange var userRepository = new Mock <IRepositoryAsync <UserEntity> >(); var getUser = new GetUser( userRepository.Object); // Act Action act = () => getUser.GetByEmail(_user.Email); // Assert Assert.Throws <ObjectNotFoundException>(act); }
public void GetByEmail_GetUser_User() { // Arrange var userRepository = new Mock <IRepositoryAsync <UserEntity> >(); var getUser = new GetUser( userRepository.Object); var usersQueryable = _users.AsQueryable(); userRepository.Setup(r => r.GetAll()) .Returns(usersQueryable); // Act var result = getUser.GetByEmail(_users.ElementAt(0).Email); // Assert Assert.NotNull(result); Assert.Equal(_users.ElementAt(0).Email, result.Email); }