public async Task GetInt_ProductNotFound_Returns404() { var productServiceMock = new Mock <IProductService>(); productServiceMock.Setup(service => service.Get(1)) .Returns(Task.FromResult <ProductEntity?>(null)); var tested = new ProductsController(ServiceMockHelper.CreateLoggerMock <ProductsController>(), productServiceMock.Object, ServiceMockHelper.CreateMapperMock()); var result = await tested.Get(1); Assert.IsInstanceOf <NotFoundResult>(result.Result); }
public async Task SetDescription_NotFound_Returns404() { var productServiceMock = new Mock <IProductService>(); productServiceMock.Setup(service => service.SetDescription(1, null)) .Returns(Task.FromResult(UpdateResult.NotFound)); var tested = new ProductsController(ServiceMockHelper.CreateLoggerMock <ProductsController>(), productServiceMock.Object, ServiceMockHelper.CreateMapperMock()); var result = await tested.SetDescription(1, null); productServiceMock.VerifyAll(); Assert.IsInstanceOf <NotFoundResult>(result); }
public void Get_InvalidPagingParams_Returns400(uint?offset, uint?limit) { var tested = new ProductsController(ServiceMockHelper.CreateLoggerMock <ProductsController>(), new Mock <IProductService>().Object, ServiceMockHelper.CreateMapperMock()); var result = tested.Get(offset, limit).Result; Assert.IsInstanceOf <BadRequestObjectResult>(result); }