public ReceiptProduct MapReceiptProduct(Product product) { if (product == null) { throw new NullReferenceException($"Receveived product is null!"); } var productReceipt = new ReceiptProduct(); try { productReceipt.ProductName = product.ProductName; productReceipt.Barcode = product.Barcode; productReceipt.Amount = product.Amount; productReceipt.Discount = product.Discount; productReceipt.ProductPrice = product.Price; productReceipt.ProductPriceWithDiscount = _calculateProductPrice.Calculate(product, 1); productReceipt.Total = _calculateProductPrice.Calculate(product, product.Amount); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); Console.WriteLine(ex.Source); Console.WriteLine(ex.InnerException); throw; } return(productReceipt); }
public void CalculateProductPrice_ShouldReturnProductPrice_WhenNoDiscount() { // Assemble var product = new Product() { ProductName = "Kaaaas", Price = 5.49M, Discount = Discount.NoDiscount }; // Act var price = _calculateProductPrice.Calculate(product, 1); // Assert Assert.AreEqual(product.Price, price); }