// GET: Postage public ActionResult Index(string price = "", string weight = "", string size = "") { if (string.IsNullOrEmpty(price) || string.IsNullOrEmpty(weight) || string.IsNullOrEmpty(size)) { return(View()); } var postages = PostageCalculator.GetPostages(weight, price, size).OrderBy(x => x.Price); var model = new PostageModel { Economy = postages.FirstOrDefault(x => x.Type == PostageCalculator.ServiceType.Economy), Standard = postages.FirstOrDefault(x => x.Type == PostageCalculator.ServiceType.Standard), Express = postages.FirstOrDefault(x => x.Type == PostageCalculator.ServiceType.Express), Price = price, Weight = weight, Size = size == "LL" ? "Large Letter" : size == "SP" ? "Small Parcel" : "Parcel" }; model.Alternatives = postages.Where(x => x.Name != model.Economy.Name && x.Name != model.Standard.Name && x.Name != model.Express.Name); return(View(model)); }
public void should_caculate_ZF_postage_for_oven() { var oven = new Oven(1); var postage = new PostageCalculator().GetPostage(new List <IPostable> { oven }, m_Zt); Assert.AreEqual(30, postage); }
public void should_caculate_ZT_postage_for_Food_More_Than_5KG() { var food = new Food(7); var postage = new PostageCalculator().GetPostage(new List <IPostable> { food }, m_Zt); Assert.AreEqual(18, postage); }
public void should_caculate_ZT_postage_for_book_More_Than_5KG() { var book = new Book(7); var postage = new PostageCalculator().GetPostage(new List <IPostable> { book }, m_Zt); Assert.AreEqual(18, postage); }
public void should_caculate_SF_postage_for_food() { var food = new Food(4); var postage = new PostageCalculator().GetPostage(new List <IPostable> { food }, m_Sf); Assert.AreEqual(16, postage); }
public void should_caculate_SF_postage_for_book() { var book = new Book(3); var postage = new PostageCalculator().GetPostage(new List <IPostable> { book }, m_Sf); Assert.AreEqual(9, postage); }
public void should_SF_increase_postage_for_Oven_by_50_percent_in_busy_seaon() { var items = new List <IPostable> { new Oven(2, 10) }; var calculator = new PostageCalculator(new BusySeasonCalculator(new ShunFengCalculator())); Assert.AreEqual(80 * 1.5, calculator.GetPostage(items), 0.001); }
public void should_ZT_increase_postage_for_food_by_20_percent_in_busy_seaon() { var items = new List <IPostable> { new Food(2) }; var calculator = new PostageCalculator(new BusySeasonCalculator(new ZhongTongCalculator())); Assert.AreEqual(10 * 1.2, calculator.GetPostage(items), 0.001); }
public void should_SF_increase_postage_for_book_by_15_percent_in_busy_seaon() { var items = new List <IPostable> { new Book(2) }; var calculator = new PostageCalculator(new BusySeasonCalculator(new ShunFengCalculator())); Assert.AreEqual(6 * 1.15, calculator.GetPostage(items), 0.001); }
public void should_get_shunfeng_postage() { var items = new List <IPostable> { new Book(2), new Food(4) }; var calculator = new PostageCalculator(new ShunFengCalculator()); var actualPostage = calculator.GetPostage(items); Assert.AreEqual(22, actualPostage); }
public void should_get_postage_for_zhongtong() { var items = new List <IPostable> { new Book(2), new Food(4), new Oven(2, 5) }; var calculator = new PostageCalculator(new ZhongTongCalculator()); var actualPostage = calculator.GetPostage(items); Assert.AreEqual(50, actualPostage); }
/// <summary> /// Returns a view result with the order. /// FeatureFlag logic inside the code. /// </summary> public IActionResult OrderVersion1() { var order = _orderSystem.GetOrder(); var postageCalculator = new PostageCalculator(); var postage = 0D; if (NewPostageCalculationFeature.FeatureEnabled) { // use the new calculation formula to calculate the postage postage = postageCalculator.CalculateUsingNewFormula(order); } else { // use the existing calculation formula to calculate the postage postage = postageCalculator.Calculate(order); } return(View("order", new OrderViewModel(order, postage))); }