public async void GetClientCatalogWithIncorrectIdReturnsNotFound() { using (var context = DbTestContext.GenerateContextWithData()) using (var controller = new ClientCatalogsController(context, _mapper)) { var result = await controller.GetClientCatalog(99); Assert.IsType <NotFoundResult>(result); } }
public async void GetClientCatalogModelStateErrorReturnsBadRequest() { using (var context = DbTestContext.GenerateContextWithData()) using (var controller = new ClientCatalogsController(context, _mapper)) { controller.ModelState.AddModelError("an error", "some error"); var result = await controller.GetClientCatalog(1); Assert.IsType <BadRequestObjectResult>(result); } }
public async void GetClientCatalogByIdReturnsSingleClientCatalog() { using (var context = DbTestContext.GenerateContextWithData()) using (var controller = new ClientCatalogsController(context, _mapper)) { var result = await controller.GetClientCatalog(3); var okObjectResult = Assert.IsType <OkObjectResult>(result); var resultValue = okObjectResult.Value; ClientCatalogDto p3 = GetTestClientCatalogDto(3); Assert.NotNull(resultValue); Assert.IsType <ClientCatalogDto>(resultValue); ClientCatalogDto p = (ClientCatalogDto)resultValue; Assert.True(p.Equals(p3)); Assert.True(p.Equals(p3, true)); } }