public async Task FilterByName_ReturnsNotContent_GivenNull() { // Arrange var mockRepo = new Mock <IServiceService <Service> >(); var returning = "invalid"; var dbMock = GetServices(null, returning); mockRepo.Setup(x => x.FilterByName(It.IsAny <string>())).Returns(dbMock); var controller = new ServicesController(mockRepo.Object); // Act var result = await controller.FilterByName("Test"); // Assert Assert.IsType <NoContentResult>(result); }
public async Task FilterByName_ReturnsServiceDTO_GivenService() { // Arrange var mockRepo = new Mock <IServiceService <Service> >(); var dbMock = GetServices(CodeServiceUsersControllerTests.GetListSync()); mockRepo.Setup(x => x.FilterByName(It.IsAny <string>())).Returns(dbMock); var controller = new ServicesController(mockRepo.Object); // Act var result = await controller.FilterByName("Test"); // Assert var okResult = Assert.IsType <OkObjectResult>(result); var returnService = Assert.IsType <List <ServiceDTO> >(okResult.Value); Assert.Equal(3, returnService.Count); Assert.Equal("Test One", returnService.First().Name); }