public void testMissingProductCode() { Assert.Throws <InvalidOperationException>(() => { var builder = new ArticleBuilder(); builder.SetUnitPrice(unitPrice: 1.25M); builder.BuildArticle(); }); }
public void Setup() { var builder = new ArticleBuilder(); builder.SetProductCode(productCode: "A"); builder.SetUnitPrice(unitPrice: 1.25M); builder.SetBulkPriceCondition(quantity: 3, price: 3.00M); article = builder.BuildArticle(); }
public void testBaseUnitPriceArticle() { var builder = new ArticleBuilder(); builder.SetProductCode(productCode: "A"); builder.SetUnitPrice(unitPrice: 1.25M); var article = builder.BuildArticle(); Assert.AreEqual("A", article.productCode); Assert.AreEqual(1.25M, article.CalculatePrice(1)); }
public void TestCalculatePriceForKgProduct() { var builder = new ArticleBuilder(); builder.SetProductCode(productCode: "Banana"); builder.SetUnitPrice(unitPrice: 2.99M); article = builder.BuildArticle(); Assert.AreEqual(4.57, article.CalculatePrice(quantity: 1.53M), "Rounded to 2dp"); Assert.AreEqual(3.02, article.CalculatePrice(quantity: 1.01M), "Rounded to 2dp"); }
public void testBulkPricingArticle() { var builder = new ArticleBuilder(); builder.SetProductCode(productCode: "A"); builder.SetUnitPrice(unitPrice: 1.25M); builder.SetBulkPriceCondition(quantity: 3, price: 3.00M); var article = builder.BuildArticle(); Assert.AreEqual("A", article.productCode); Assert.AreEqual(3.0M, article.CalculatePrice(3)); }
public void testOutOfRangeBulkPricingArticle() { Assert.Throws <ArgumentOutOfRangeException>(() => { var builder = new ArticleBuilder(); builder.SetProductCode(productCode: "A"); builder.SetUnitPrice(unitPrice: 1.25M); builder.SetBulkPriceCondition(quantity: 1, price: 3.00M); builder.BuildArticle(); }, "Bulk quantity should be > 1"); Assert.Throws <ArgumentOutOfRangeException>(() => { var builder = new ArticleBuilder(); builder.SetProductCode(productCode: "A"); builder.SetUnitPrice(unitPrice: 1.25M); builder.SetBulkPriceCondition(quantity: 2, price: 0.00M); builder.BuildArticle(); }, "Bulk price should be > 0"); }