public void GetClientCatalogsEmptyContextNotFound() { using (var context = DbTestContext.GenerateEmptyContext()) using (var controller = new ClientCatalogsController(context, _mapper)) { var result = controller.GetClientCatalogs(); Assert.IsType <NotFoundResult>(result); } }
public void GetClientCatalogsReturnsListOfAuthors() { using (var context = DbTestContext.GenerateContextWithData()) using (var controller = new ClientCatalogsController(context, _mapper)) { var result = controller.GetClientCatalogs(); ClientCatalogDto p3 = GetTestClientCatalogDto(3); var okObjectResult = Assert.IsType <OkObjectResult>(result); var resultValue = okObjectResult.Value; Assert.IsAssignableFrom <IEnumerable <ClientCatalogDto> >(resultValue); Assert.NotEmpty((IEnumerable <ClientCatalogDto>)resultValue); IEnumerable <ClientCatalogDto> resultValueList = (IEnumerable <ClientCatalogDto>)resultValue; Assert.Equal(10, resultValueList.Count()); ClientCatalogDto p = (ClientCatalogDto)resultValueList.Where(r => r.Id == 3).FirstOrDefault(); Assert.True(p.Equals(p3)); Assert.True(p.Equals(p3, true)); } }