public void TestInitialize() { productForDetailDto = new ProductForDetailDto() { Id = 1, Name = "TestItem", UnitPrice = 12, Qty = 5, Description = "Test Item for testing", ProductCategoryId = 1, PhotoUrl = "www.google.lk" }; productForListDto = new ProductForListDto() { Id = 1, Name = "TestProductList Item", UnitPrice = 12, ProductCategoryId = 1, PhotoUrl = "www.google.lk" }; _mockUnitOfWork = new Mock <IUnitOfWork>(); _mockProductRepository = new Mock <IProductRepository>(); //_mockProductRepository.Setup(m =>m.GetProducts()).ReturnsAsync(productForListDto); _mockProductRepository.Setup(m => m.GetProduct(1)).ReturnsAsync(productForDetailDto); _mockUnitOfWork.Setup(m => m.ProductRepository).Returns(_mockProductRepository.Object); }
public async Task <IActionResult> GetProduct(int id) { ProductForDetailDto product = await _productsManager.GetProduct(id); return(Ok(product)); }