示例#1
0
        public void CreateOrder_OneOfEachParcel_WithoutSpeedyDelivery()
        {
            List <Item> items = new List <Item>()
            {
                new Item(height: 5, width: 5, depth: 5, weight: 1),
                new Item(height: 30, width: 30, depth: 30, weight: 3),
                new Item(height: 80, width: 80, depth: 80, weight: 6),
                new Item(height: 120, width: 120, depth: 120, weight: 10)
            };

            ParcelCostCalculator calculator = new ParcelCostCalculator();

            Order order = calculator.CreateOrder(items);

            Assert.IsFalse(order.IsSpeedyDelivery);
            Assert.AreEqual(0.00M, order.SpeedyDeliveryCost);
            Assert.AreEqual(51.00M, order.ParcelCosts);
            Assert.AreEqual(51.00M, order.TotalCost);
            Assert.AreEqual(4, order.Parcels.Count);

            Assert.IsInstanceOfType(order.Parcels[0], typeof(SmallParcel));
            Assert.IsInstanceOfType(order.Parcels[1], typeof(MediumParcel));
            Assert.IsInstanceOfType(order.Parcels[2], typeof(LargeParcel));
            Assert.IsInstanceOfType(order.Parcels[3], typeof(ExtraLargeParcel));
        }
示例#2
0
        public void CreateOrder_OneSmallItem_OneSmallParcel_OutsideWeight()
        {
            List <Item> items = new List <Item>()
            {
                new Item(height: 5, width: 5, depth: 5, weight: 2)
            };

            ParcelCostCalculator calculator = new ParcelCostCalculator();

            Order order = calculator.CreateOrder(items);

            Assert.IsFalse(order.IsSpeedyDelivery);
            Assert.AreEqual(0.00M, order.SpeedyDeliveryCost);
            Assert.AreEqual(2.00M, order.ExtraWeightCost);
            Assert.AreEqual(3.00M, order.ParcelCosts);
            Assert.AreEqual(5.00M, order.TotalCost);
            Assert.AreEqual(1, order.Parcels.Count);
            Assert.IsInstanceOfType(order.Parcels[0], typeof(SmallParcel));
        }
示例#3
0
        public void CreateOrder_OneHeavyItem_OneHeavyParcel_OutsideWeight(int height, int width, int depth)
        {
            List <Item> items = new List <Item>()
            {
                new Item(height, width, depth, weight: 55, isHeavyItem: true)
            };

            ParcelCostCalculator calculator = new ParcelCostCalculator();

            Order order = calculator.CreateOrder(items);

            Assert.IsFalse(order.IsSpeedyDelivery);
            Assert.AreEqual(5.00M, order.ExtraWeightCost);
            Assert.AreEqual(0.00M, order.SpeedyDeliveryCost);
            Assert.AreEqual(50.00M, order.ParcelCosts);
            Assert.AreEqual(55.00M, order.TotalCost);
            Assert.AreEqual(1, order.Parcels.Count);
            Assert.IsInstanceOfType(order.Parcels[0], typeof(HeavyParcel));
        }