public async Task <ActionResult <List <CategoryResponse> > > List() { var categories = await _categoryService.List(); var response = _categoryConverter.ToResponse(categories); return(Ok(response)); }
public void Test_ToListResponse_id_is_converted() { var category = new CategoryModel { Id = 5 }; var categoryList = new List <CategoryModel> { category }; var responseList = _categoryConverter.ToResponse(categoryList); responseList.First().Id.Should().Be(category.Id); }
public async Task Test_controller_lists_out_all_categories_from_service() { var categoryList = new List <CategoryModel>(); var expectedResult = new List <CategoryResponse>(); A.CallTo(() => _categoryService.List()).Returns(categoryList); A.CallTo(() => _categoryConverter.ToResponse(categoryList)).Returns(expectedResult); var response = await _categoryController.List(); response.Result.Should().BeAssignableTo <OkObjectResult>(); var result = response.Result.As <OkObjectResult>(); result.Value.Should().BeAssignableTo <List <CategoryResponse> >(); result.Value.As <List <CategoryResponse> >().Should().BeEquivalentTo(expectedResult); }