Esempio n. 1
0
        public static ShippingDetailInfo GetAirLetterPlainShippingDetailInstance()
        {
            ShippingDetailInfo instance = new ShippingDetailInfo();

            instance.DeliveryMethod     = DeliveryMethodEnum.Air;
            instance.PackageInfo        = PackageInfoFactory.GetLetterPackageInstance("Plain");
            instance.DestinationAddress = address1;
            instance.OriginAddress      = address2;

            return(instance);
        }
 private PackageInfo GetPackageInfo()
 {
     if (cbPackageType.SelectedItem.ToString().CompareTo("Box") == 0)
     {
         return(PackageInfoFactory.GetBoxPackageInstance(
                    Convert.ToInt32(numHeight.Value.ToString()),
                    Convert.ToInt32(numWidth.Value.ToString()),
                    Convert.ToInt32(numDepth.Value.ToString())));
     }
     else
     {
         return(PackageInfoFactory.GetLetterPackageInstance(cbLetterType.SelectedItem.ToString()));
     }
 }
        public void ProcessFailPostCodeTest()
        {
            JustInTimeShippingFacade target = JustInTimeShippingFacade.GetInstance();
            ShippingDetailInfo       detail = new ShippingDetailInfo();

            detail.PackageInfo        = PackageInfoFactory.GetLetterPackageInstance("Plain");
            detail.DeliveryMethod     = DeliveryMethodEnum.Ground;
            detail.OriginAddress      = new AddressInfo("John Doe", "Happy Street", "KL", "Selangor", "5600011");
            detail.DestinationAddress = new AddressInfo("Jane Doe", "Sad Street", "KL", "Selangor", "5600110");

            IResult result = target.Execute(detail);

            Assert.IsFalse(result.IsSuccess);
            Assert.IsTrue(result.Message.Length > 0);
        }
        public void ProcessGroundPackageTest()
        {
            ShippingDetailInfo input = new ShippingDetailInfo();

            input.PackageInfo        = PackageInfoFactory.GetLetterPackageInstance("Plain");
            input.PackageInfo.Weight = 20;
            input.DeliveryMethod     = DeliveryMethodEnum.Ground;
            input.OriginAddress      = new AddressInfo("John Doe", "Happy Street", "KL", "Selangor", "56000");
            input.DestinationAddress = new AddressInfo("Jane Doe", "Sad Street", "KL", "Selangor", "56000");


            ShippingCostCommand target = new ShippingCostCommand();

            ShippingDetailInfo actual;

            actual = target.Execute(input);

            Assert.IsTrue(input.Cost == 1.25);
        }
        public void ProcessTest()
        {
            ShippingDetailInfo input = new ShippingDetailInfo();

            input.PackageInfo        = PackageInfoFactory.GetLetterPackageInstance("Plain");
            input.DeliveryMethod     = DeliveryMethodEnum.Ground;
            input.OriginAddress      = new AddressInfo("John Doe", "Happy Street", "KL", "Selangor", "56000");
            input.DestinationAddress = new AddressInfo("Jane Doe", "Sad Street", "KL", "Selangor", "56000");

            SamWeightAdapter target = new SamWeightAdapter();

            double actual;

            Assert.IsTrue(input.PackageInfo.Weight == 0);

            actual = target.GetWeight();

            Assert.IsTrue(actual > 0);
        }