public void Mapper_Maps_ProductViewModel_To_Product() { var expectedStockQuantity = 50; var expectedPrice = 6.00; var productViewModel = CatalogServiceTestHelper.GetFakeProductViewModel(); var product = _mapper.Map <Product>(productViewModel); Assert.IsType <Product>(product); Assert.Equal(expectedStockQuantity, product.Quantity); Assert.Equal(expectedPrice, product.Price); }
public async void Post_Catalog_Item_Success() { var expectedProduct = CatalogServiceTestHelper.GetFakeProduct(); _repository.Setup(x => x.UpdateProductAsync ( It.Is <Product>(y => y == expectedProduct) )) .Returns(Task.CompletedTask); //Act var controller = new ProductController(_repository.Object, _mapper, _env.Object); var actionResult = await controller.Post(CatalogServiceTestHelper.GetFakeProductViewModel()); //Assert var redirectToActionResult = Assert.IsType <CreatedAtActionResult>(actionResult); Assert.Equal("Get", redirectToActionResult.ActionName); Assert.Equal(201, redirectToActionResult.StatusCode); }