public void ParcelFactory_GetParcel_Large()
        {
            var parcelFactory = new ParcelFactory();

            var result = parcelFactory.GetParcel(8, 100, 80, 120);

            Assert.IsInstanceOfType(result, typeof(LargeParcel));
        }
        public void ParcelFactory_GetParcel_Small()
        {
            var parcelFactory = new ParcelFactory();

            var result = parcelFactory.GetParcel(10, 1, 3, 5);

            Assert.IsInstanceOfType(result, typeof(SmallParcel));
        }
        public void ParcelFactory_GetParcel_Medium()
        {
            var parcelFactory = new ParcelFactory();

            var result = parcelFactory.GetParcel(9, 10, 10, 23);

            Assert.IsInstanceOfType(result, typeof(MediumParcel));
        }
        public void ParcelFactory_GetParcel_Heavy()
        {
            var parcelFactory = new ParcelFactory();

            var result = parcelFactory.GetParcel(41, 10, 20, 10);

            Assert.IsInstanceOfType(result, typeof(HeavyParcel));
        }
        public void ParcelFactory_GetParcel_Rejected()
        {
            var parcelFactory = new ParcelFactory();

            var result = parcelFactory.GetParcel(51, 10, 10, 10);

            Assert.IsInstanceOfType(result, typeof(RejectParcel));
        }
Пример #6
0
 public ParcelService()
 {
     _parcelList = new List <ParcelEntity>()
     {
         ParcelFactory.CreateParcel(ParcelType.Small),
         ParcelFactory.CreateParcel(ParcelType.Medium),
         ParcelFactory.CreateParcel(ParcelType.Large),
     };
 }
Пример #7
0
        static void TestInvalidParcelOrder()
        {
            //Assumptions - if any parcel have invalid deminsion, it can't create the whole order.
            try
            {
                var parcelFactory = new ParcelFactory();
                var parcelUtility = new ParcelOrderUtility();


                // List<double> invalidDimensions = new List<double> { 2, 30, 60, 160 , -100 };
                var InvalidParceSetting = new List <IParcelSettings>
                {
                    new ParcelSettings {
                        Dimensions = 2, Weight = 1
                    },
                    new ParcelSettings {
                        Dimensions = 30, Weight = 2
                    },
                    new ParcelSettings {
                        Dimensions = 60, Weight = 5
                    },
                    new ParcelSettings {
                        Dimensions = 160, Weight = 10
                    },
                    new ParcelSettings {
                        Dimensions = -100, Weight = -3
                    },
                };

                var parcelOrderSettings = new ParcelOrderSettings
                {
                    SpeedyShipping = true
                };
                var invlidParcelOrder = parcelUtility.GeneratePacels(parcelFactory, InvalidParceSetting, parcelOrderSettings);

                var parcelOrderHelper = new ParcelOrderHelper();
                var displayData       = parcelOrderHelper.DisplayOrderSummary(invlidParcelOrder.GetParcelOrderDetails());

                foreach (var result in displayData)
                {
                    Console.WriteLine(result);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Пример #8
0
 public ParcelFactoryTests()
 {
     parcelFactory = new ParcelFactory();
 }