コード例 #1
0
ファイル: ArticleBuilderTest.cs プロジェクト: kaga/Pos
 public void testMissingProductCode()
 {
     Assert.Throws <InvalidOperationException>(() =>
     {
         var builder = new ArticleBuilder();
         builder.SetUnitPrice(unitPrice: 1.25M);
         builder.BuildArticle();
     });
 }
コード例 #2
0
        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();
        }
コード例 #3
0
ファイル: ArticleBuilderTest.cs プロジェクト: kaga/Pos
        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));
        }
コード例 #4
0
        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");
        }
コード例 #5
0
ファイル: ArticleBuilderTest.cs プロジェクト: kaga/Pos
        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));
        }
コード例 #6
0
ファイル: ArticleBuilderTest.cs プロジェクト: kaga/Pos
        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");
        }