예제 #1
0
        public void TestMultipleParcelDiscount(string[] parcels, decimal expectedDiscount)
        {
            //arrange

            var order = new List <Parcel>();

            // act
            var calc = new CostCalculator();
            var res  = calc.CalculateCharges(order);

            //assert
            Assert.Fail("not implemented yet");
        }
예제 #2
0
        public void TestSizeCharge(int height, int width, int length, ParcelType type, decimal cost)
        {
            // arrange
            var parcel = new Parcel(height, width, length, 0);

            // act
            var calc         = new CostCalculator();
            var parcelCharge = calc.CalculateCharges(new List <Parcel>()
            {
                parcel
            }).Charges.First();

            // assert
            Assert.AreEqual(cost, parcelCharge.TotalCharge);
            Assert.AreEqual(type, parcelCharge.Type);
        }
예제 #3
0
        public void TestHeavyParcelCharge()
        {
            //arrange
            var heavyParcel = new Parcel(4, 4, 5, 60);

            // act
            var calc = new CostCalculator();
            var res  = calc.CalculateCharges(new List <Parcel>()
            {
                heavyParcel
            });

            //asert
            Assert.AreEqual(ParcelType.Heavy, res.Charges.First().Type);
            Assert.AreEqual(10, res.Charges.First().OverweightSurcharge);
            Assert.AreEqual(50, res.Charges.First().SizeCharge);
        }
예제 #4
0
        public void TestOrderTotals()
        {
            // arrange
            var order = new List <Parcel>
            {
                new Parcel(12, 12, 12, 0),
                new Parcel(60, 60, 60, 0),
                new Parcel(110, 110, 110, 0)
            };

            //act
            var calc         = new CostCalculator();
            var orderCharges = calc.CalculateCharges(order);

            // assert
            Assert.AreEqual(48, orderCharges.StandardShippingTotal);
            Assert.AreEqual(96, orderCharges.SpeedyShippingTotal);
            Assert.AreEqual(3, orderCharges.Charges.Count());
        }
예제 #5
0
        public void TestOverweightCharge(int weight, ParcelType type, decimal overweightCharge)
        {
            // arrange
            Dictionary <ParcelType, Parcel> testParcels = new Dictionary <ParcelType, Parcel>()
            {
                { ParcelType.Small, new Parcel(2, 2, 2, weight) },
                { ParcelType.Medium, new Parcel(20, 20, 20, weight) },
                { ParcelType.Large, new Parcel(70, 70, 70, weight) },
                { ParcelType.XL, new Parcel(120, 120, 120, weight) },
            };

            var parcel = testParcels[type];

            // act
            var calc = new CostCalculator();
            var res  = calc.CalculateCharges(new List <Parcel>()
            {
                parcel
            });

            // assert
            Assert.AreEqual(overweightCharge, res.Charges.First().OverweightSurcharge);
        }