Ejemplo n.º 1
0
        public void TestOfferDiscount()
        {
            //Arrange
            IBaseItem item      = new Item("PommesDeluxe", "12345678", 1, 25);
            IBaseItem item2     = new Item("PommesDeluxe", "12345678", 2.50, 25);
            Offer     offer     = new Offer(DateTime.Now);
            OfferLine offerLine = new OfferLine(item, 100);

            //Act
            offer.AddOfferLine(offerLine);
            offer.OfferDiscountPercent = 20;

            //Assert
            Assert.AreEqual(80, offer.OfferTotal);
            OfferLine offerLine2 = new OfferLine(item2, 4);

            offer.AddOfferLine(offerLine2);
            Assert.AreEqual(88, offer.OfferTotal);
            offer.OfferDiscountPercent = 10;
            Assert.AreEqual(99, offer.OfferTotal);
            OfferLine offerLine3 = new OfferLine(item, 100)
            {
                PercentDiscount = 20
            };

            offer.AddOfferLine(offerLine3);
            Assert.AreEqual(171, offer.OfferTotal);
        }
Ejemplo n.º 2
0
        public void AddOfferLine(IBaseItem myItem, int quantity)
        {
            IExtendOfferLine newOfferLine = new OfferLine(myItem, quantity);

            OfferLines.Add(newOfferLine);
            newOfferLine.APWC += NotifyPropertyChanged;
            string[] propertiesChanged = { nameof(OfferTotal), nameof(NoOfTotalPackages), nameof(NoOfTotalPallets), nameof(OfferLinesSubtotal), nameof(TotalDiscountedPrice), nameof(TotalPercentDiscount) };
            NotifyPropertiesChanged(propertiesChanged);
        }
Ejemplo n.º 3
0
        public void TestOfferLineTotal()
        {
            //Arrange
            IBaseItem item       = new Item("PommesDeluxe", "12345678", 10.5, 25);
            OfferLine offerLine1 = new OfferLine(item, 2);

            //Act
            //Assert
            Assert.AreEqual(21, offerLine1.OfferLineTotal);
        }
Ejemplo n.º 4
0
        public void OfferLineTotalTest()
        {
            //Arrange
            IBaseItem item      = new Item("Kyllinge vinger", "123", 20.25, 25);
            OfferLine offerLine = new OfferLine(item, 100);

            //Act
            //Assert
            Assert.AreEqual(2025, offerLine.OfferLineTotal);
        }
Ejemplo n.º 5
0
        public void AddOfferLineToOffer()
        {
            //Arrange
            IBaseItem item      = new Item("PommesDeluxe", "12345678", 25.95, 25);
            OfferLine offerLine = new OfferLine(item, 20);
            Offer     offer     = new Offer(DateTime.Now);

            //Act
            offer.AddOfferLine(offerLine);
            //Assert
            Assert.AreEqual(1, offer.OfferLines.Count);
        }
Ejemplo n.º 6
0
        public void PercentDiscountMathTest()
        {
            //Arrange
            IBaseItem item      = new Item("Kyllinge vinger", "123", 20.25, 25);
            OfferLine offerLine = new OfferLine(item, 100)
            {
                PercentDiscount = 20
            };

            //Act
            //Assert
            Assert.AreEqual(1620, offerLine.OfferLineTotal);
            Assert.AreEqual(16.2, offerLine.DiscountedPrice);
        }
Ejemplo n.º 7
0
        public void DiscountedPriceMathTest()
        {
            //Arrange
            IBaseItem item      = new Item("Kyllinge vinger", "123", 20.25, 25);
            OfferLine offerLine = new OfferLine(item, 100)
            {
                DiscountedPrice = 15
            };

            //Act
            //Assert
            Assert.AreEqual(1500, offerLine.OfferLineTotal);
            Assert.AreEqual(25.9259259259, offerLine.PercentDiscount, 5);
        }
Ejemplo n.º 8
0
        public void TestOfferTotal()
        {
            //Arrange
            IBaseItem item       = new Item("PommesDeluxe", "12345678", 10.5, 25);
            IBaseItem item2      = new Item("PommesDeluxe2", "123456782", 20.25, 25);
            Offer     testOffer  = new Offer(new DateTime(2017, 11, 01));
            OfferLine offerLine1 = new OfferLine(item, 5);   //52.5 total
            OfferLine offerLine2 = new OfferLine(item2, 10); //202,5 total

            //Act
            //Assert
            Assert.AreEqual(0, testOffer.OfferTotal);
            testOffer.AddOfferLine(offerLine1);
            Assert.AreEqual(52.5, testOffer.OfferTotal);
            testOffer.AddOfferLine(offerLine2);
            Assert.AreEqual(255, testOffer.OfferTotal);
        }