Ejemplo n.º 1
0
        public void TestRetreiveAllSalesTax()
        {
            // arrange
            ISalesTaxManager salesTaxManager = new SalesTaxManager(_fakeSalesTaxAccessor);
            var list     = new List <SalesTax>();
            int expected = 2;

            // act
            list = salesTaxManager.RetrieveAllSalesTax();
            int actual = list.Count;

            // assert
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 2
0
        public void TestSales()
        {
            var cat1=new GoodCategory("cat1");
            var cat2=new GoodCategory("cat2");
            var cat3=new GoodCategory("cat3");
            var cat4=new GoodCategory("cat4");

            var listcat1=new List<GoodCategory>() {
                            new GoodCategory("cat2")
                        };

            var listcat12=new List<GoodCategory>() {
                        new GoodCategory("cat1"),
                        new GoodCategory("cat2")
                    };

            taxes= new System.Collections.Generic.List<SalesTax>( ) {
                    new SalesTax( "tax5",5,listcat1),
                    new SalesTax( "tax10",10,listcat12)
            };
            Good good = new Good("good1", 10M, cat1);
            Good good2 = new Good("good2", 13.11M, cat1);
            Good good3 = new Good("good3", 17.01M, cat2);
            SalesTaxManager salestaxmgr = new SalesTaxManager(taxes);
            /***
             *  total= 10 + rounttoupper0.05(10 * 10 /100) = 10 + rounttoupper0.5(1) =10 +1 =11
             * */
            Assert.AreEqual(1M, salestaxmgr.computeTax(good));

            Assert.AreEqual( 11M, salestaxmgr.computeTotal(good));
            /***
             *  total= 13.11 + rounttoupper0.05(13.11 * 10 /100)
             *       = 13.11 + rounttoupper0.05(1.311)
             *       = 13.11 + 1.35 = 14.46
             * */
            Assert.AreEqual(1.35M, salestaxmgr.computeTax(good2));

            Assert.AreEqual(14.46M ,salestaxmgr.computeTotal(good2) );

            /***
             *  total= 17.01 + rounttoupper0.05(17.01 * 10 /100) +rounttoupper0.05(17.01  * 5 /100)
             *       = 17.01  + rounttoupper0.05(1.701) + rounttoupper0.05(0.08505)
             *       = 17.01  + 1.75 + 0.9 =
             *       = 17.01 + 2.65 =  19.66
             * */
            Assert.AreEqual(2.65M, salestaxmgr.computeTax(good3));
            Assert.AreEqual( 19.66M ,salestaxmgr.computeTotal(good3));
        }
Ejemplo n.º 3
0
 public void Initialize() => SalesManager = new SalesTaxManager();