public void GetClientListWithFilters() { var data = ClientsDataForTest.GetTestClientsWithPurchases().ToList(); var mockContext = new Mock <SalesReportContext>(); mockContext.Setup(c => c.Clients).Returns(DbContextMock.GetQueryableMockDbSet(data)); var repository = new ClientRepository(mockContext.Object); var result = repository.GetClientListWithFilters(null, null, null).ToList(); Assert.Equal(4, result.Count); Assert.NotNull(result); result = repository.GetClientListWithFilters(dateTimeFrom, dateTimeTo, null).ToList(); Assert.Equal(2, result.Count); Assert.NotNull(result); result = repository.GetClientListWithFilters(null, null, clientName).ToList(); Assert.Single(( IEnumerable )result); Assert.NotNull(result); result = repository.GetClientListWithFilters(dateTimeFrom, dateTimeTo, clientName).ToList(); Assert.Single(( IEnumerable )result); Assert.NotNull(result); }
public void GetClientList() { var mock = new Mock <IClientRepository <Client> >(); mock.Setup(repo => repo.GetClientListWithFilters(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(ClientsDataForTest.GetTestClientsWithPurchases()); var clientController = new ClientsController(mock.Object); var result = clientController.GetClientList(null, null, null); Assert.Equal(4, result.Value.ToList().Count); Assert.NotNull(result.Value); }