public void SpecialCosts_MixDays() { var costEvaluationService = new CostEvaluationService(HourCostsRepo( new HourCostEntity { Cost = 1000, IsGeneral = true }, new HourCostEntity { Start = 12, End = 14, DayType = DiscountDayTypeEnum.Weekend | DiscountDayTypeEnum.Workday, Cost = 250 }, new HourCostEntity { Start = 17, End = 20, DayType = DiscountDayTypeEnum.Workday, Cost = 500 }, new HourCostEntity { Start = 15, End = 19, DayType = DiscountDayTypeEnum.Weekend, Cost = 750 } ), PromoCodeRepo(), _dateService); var date = new DateTime(2018, 6, 8); double result = costEvaluationService.EvaluateBookingCost(date.AddHours(10), date.AddHours(23).AddDays(1), string.Empty).TotalCost; // 2000 // 750 // 2000 // 2000 // 15000 // 750 // 3750 // 3000 Assert.AreEqual(29250, result); }
public void EvaluateBookingCost_1_3h() { var costEvaluationService = new CostEvaluationService(HourCostsRepo( new HourCostEntity { Cost = 100, IsGeneral = true } ), PromoCodeRepo(), _dateService); double result = costEvaluationService.EvaluateBookingCost(DateTime.Today.AddHours(10), DateTime.Today.AddHours(11).AddMinutes(18), string.Empty).TotalCost; Assert.AreEqual(130, result); }
public void SpecialCosts_WorkdaySimple() { var costEvaluationService = new CostEvaluationService(HourCostsRepo( new HourCostEntity { Cost = 100, IsGeneral = true }, new HourCostEntity { Start = 10, End = 17, DayType = DiscountDayTypeEnum.Workday, Cost = 50 } ), PromoCodeRepo(), _dateService); var date = new DateTime(2018, 6, 4); double result = costEvaluationService.EvaluateBookingCost(date.AddHours(10), date.AddHours(18), string.Empty).TotalCost; Assert.AreEqual(400, result); }
public void PromoCode_IgnoreIfExpired() { var costEvaluationService = new CostEvaluationService( HourCostsRepo(new HourCostEntity { Cost = 100, IsGeneral = true }), PromoCodeRepo(new PromoCodeEntity { Code = "promo", Discount = 27, From = _anchor.AddDays(-1), To = _anchor.AddDays(-1) }), _dateService); var date = new DateTime(2018, 6, 4); double result = costEvaluationService.EvaluateBookingCost(date.AddHours(10), date.AddHours(12), "promo").TotalCost; Assert.AreEqual(200, result); }
public void PromoCode_WithSpecialCosts() { var costEvaluationService = new CostEvaluationService(HourCostsRepo( new HourCostEntity { Cost = 100, IsGeneral = true }, new HourCostEntity { Start = 10, End = 17, DayType = DiscountDayTypeEnum.Workday, Cost = 50 } ), PromoCodeRepo(new PromoCodeEntity { Code = "promo", Discount = 27, From = _anchor, To = _anchor }), _dateService); var date = new DateTime(2018, 6, 4); double result = costEvaluationService.EvaluateBookingCost(date.AddHours(8), date.AddHours(20), "promo").TotalCost; Assert.AreEqual(584, result); }
public void SpecialCosts_StartEndBetweenIntervals() { var costEvaluationService = new CostEvaluationService(HourCostsRepo( new HourCostEntity { Cost = 1000, IsGeneral = true }, new HourCostEntity { Start = 12, End = 14, DayType = DiscountDayTypeEnum.Weekend | DiscountDayTypeEnum.Workday, Cost = 250 }, new HourCostEntity { Start = 17, End = 20, DayType = DiscountDayTypeEnum.Workday, Cost = 500 } ), PromoCodeRepo(), _dateService); var date = new DateTime(2018, 6, 8); double result = costEvaluationService.EvaluateBookingCost(date.AddHours(16), date.AddHours(17), string.Empty).TotalCost; Assert.AreEqual(1000, result); }