public void GetByPagination_GetUsersIfIndexLessZero_InvalidOperationException() { // Arrange var userRepository = new Mock <IRepositoryAsync <UserEntity> >(); var getUser = new GetUser( userRepository.Object); int invalidIndex = -1; // Act Action act = () => getUser.GetByPagination(invalidIndex); // Assert Assert.Throws <InvalidOperationException>(act); }
public void GetByPagination_GetUsers_Users() { // Arrange var userRepository = new Mock <IRepositoryAsync <UserEntity> >(); var getUser = new GetUser( userRepository.Object); userRepository.Setup(r => r.GetAll()) .Returns(_users.AsQueryable()); // Act var result = getUser.GetByPagination(0); // Assert Assert.NotNull(result); Assert.Equal(_users, result); }
public void GetByPagination_GetUsersIfUsersEnded_ObjectNotFoundException() { // Arrange var userRepository = new Mock <IRepositoryAsync <UserEntity> >(); var getUser = new GetUser( userRepository.Object); int bigIndex = 10; userRepository.Setup(r => r.GetAll()) .Returns(_users.AsQueryable()); // Act Action act = () => getUser.GetByPagination(bigIndex); // Assert Assert.Throws <ObjectNotFoundException>(act); }