public void BoxInfoFailTest() { PackageInfo pinfo = PackageInfoFactory.GetBoxPackageInstance(0, 0, 0); PackageInfoValidator target = new PackageInfoValidator(); // TODO: Initialize to an appropriate value IResult expected = ResultFactory.GetFailResultInstance("All dimension of boxes must be greater than 0"); // TODO: Initialize to an appropriate value IResult actual = target.Validate(pinfo); Assert.AreEqual(expected.IsSuccess, actual.IsSuccess); }
public void BoxInfoSuccessTest() { PackageInfo pinfo = PackageInfoFactory.GetBoxPackageInstance(20, 10, 5); pinfo.Weight = 30; PackageInfoValidator target = new PackageInfoValidator(); // TODO: Initialize to an appropriate value IResult expected = ResultFactory.GetSuccessResultInstance(); // TODO: Initialize to an appropriate value IResult actual = target.Validate(pinfo); Assert.AreEqual(expected.IsSuccess, actual.IsSuccess); }
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); }
public static ShippingDetailInfo GetGroundBoxShippingDetailInstance() { ShippingDetailInfo instance = new ShippingDetailInfo(); instance.DeliveryMethod = DeliveryMethodEnum.Ground; instance.PackageInfo = PackageInfoFactory.GetBoxPackageInstance(10, 10, 10); 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); }
public void ProcessRailBoxInsuredPackageTest() { ShippingDetailInfo input = new ShippingDetailInfo(); input.IsInsured = true; input.PackageInfo = PackageInfoFactory.GetBoxPackageInstance(10, 10, 10); input.PackageInfo.Weight = 20; input.DeliveryMethod = DeliveryMethodEnum.Rail; input.OriginAddress = new AddressInfo("John Doe", "Happy Street", "KL", "Selangor", "16000"); input.DestinationAddress = new AddressInfo("Jane Doe", "Sad Street", "KL", "Selangor", "46000"); ShippingCostCommand target = new ShippingCostCommand(); ShippingDetailInfo actual; actual = target.Execute(input); Assert.IsTrue(input.Cost == 1.275); }