Esempio n. 1
0
        public void DisplayPriceWithoutPst()
        {
            var priceWithoutPst = new ProductPriceInfo(500.0);

            _cashRegisterDisplay.DisplayProductInfo(priceWithoutPst);

            Assert.AreEqual("EUR 500.00 G\nTotal: EUR 525.00", _cashRegisterDisplay.Display, "The price of 12345 should be 500.00 with total price");
        }
Esempio n. 2
0
 public void DisplayProductInfo(ProductPriceInfo testPrice)
 {
     Display = string.Format(
         _numberFormatInfo,
         "EUR {0:###.00} G{2}\nTotal: EUR {1:###.00}",
         testPrice.NetPrice,
         SalesCalculator.CalculateCost(testPrice),
         testPrice.PstIncluded ? "P" : string.Empty);
 }
Esempio n. 3
0
        public void ProductWithPstFound()
        {
            var price = new ProductPriceInfo(100.00) { PstIncluded = true };

            IEditableCatalog catalog = CreateCatalog();

            catalog.AddPriceWithPst("23456", 100.00);
            Assert.IsTrue(catalog.HasBarcode("23456"));
            Assert.AreEqual(price, catalog["23456"]);
        }
Esempio n. 4
0
        public void ProductFound()
        {
            var price = new ProductPriceInfo(500.0);

            IEditableCatalog catalog = CreateCatalog();
            catalog.AddPriceWithoutPst("12345", 500.0);

            Assert.IsTrue(catalog.HasBarcode("12345"));
            Assert.AreEqual(price, catalog["12345"]);
        }
Esempio n. 5
0
        public void DisplayPriceWithPst()
        {
            var priceWithoutPst = new ProductPriceInfo(100.0)
                                      {
                                          PstIncluded = true,
                                      };

            _cashRegisterDisplay.DisplayProductInfo(priceWithoutPst);

            Assert.AreEqual("EUR 100.00 GP\nTotal: EUR 115.50", _cashRegisterDisplay.Display, "The price of 12345 should be 500.00 with total price");
        }
Esempio n. 6
0
        public void CunningPrice()
        {
            var priceWithoutPst = new ProductPriceInfo(9.10)
            {
                PstIncluded = true,
            };

            _cashRegisterDisplay.DisplayProductInfo(priceWithoutPst);

            Assert.AreEqual("EUR 9.10 GP\nTotal: EUR 10.52", _cashRegisterDisplay.Display, "Proposed by JB to check the problems with calculation");
        }
Esempio n. 7
0
        public void FoundProductShouldOutputPrice()
        {
            var testPrice = new ProductPriceInfo
                                           {
                                               NetPrice = 500.0,
                                               PstIncluded = false,
                                           };

            const string testBarcode = "12345";

            _mockScreenBuilder.Expect("DisplayProductInfo", testPrice);

            var mockScreen = (ICashRegisterDisplay)_mockScreenBuilder.MockInstance;

            _mockCatalogBuilder.ExpectAndReturn("get_Item", testPrice, testBarcode);
            _mockCatalogBuilder.ExpectAndReturn("HasBarcode", true, testBarcode);

            var mockCatalog = (ICatalog)_mockCatalogBuilder.MockInstance;

            var salesPoint = new SalesPoint(mockCatalog, mockScreen);

            salesPoint.OnBarcode(testBarcode);
        }
Esempio n. 8
0
 public static double CalculateCost(ProductPriceInfo price)
 {
     return price.NetPrice + CalculatePst(price) + CalculateGst(price);
 }
Esempio n. 9
0
 public static double CalculatePst(ProductPriceInfo price)
 {
     return price.PstIncluded ? Math.Round((price.NetPrice + CalculateGst(price)) * 0.1, 2) : 0;
 }
Esempio n. 10
0
 public static double CalculateGst(ProductPriceInfo price)
 {
     return Math.Round(price.NetPrice * 0.05, 2);
 }