public void TariffOfTaiguhui() { TariffOfGuanZhou tt = new TariffOfGuanZhou(); tt.DayTimezone = new TariffTimeZone(new TimeEntity(8, 0), new TimeEntity(22, 0), new ChargeUnit(30, 5)); tt.NightTimezone = new TariffTimeZone(new TimeEntity(22, 0), new TimeEntity(8, 0), new ChargeUnit(30, 10)); tt.NightTimezone.LimiteFee = 10; tt.FreeMinutes = 15; tt.FeeOf24Hour = 80; //2011-8-12 10:45 2011-8-12 8:08 16 0 0 0 0 30 Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 8, 12, 8, 8, 0), new DateTime(2011, 8, 12, 10, 45, 0)) == 30); //2011-8-12 11:52 2011-8-12 7:59 Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 8, 12, 7, 59, 0), new DateTime(2011, 8, 12, 11, 52, 0)) > 0); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 10, 30, 22, 3, 0), new DateTime(2011, 10, 31, 11, 03, 0)) > 0); }
public void TariffOfGuanZhouTest() { //广州收费时段,8:00-18:00 每小时收3元,18:00-8:00 每12小时收费10元(注意18点到8点有14个小时,所以在这个时段内超过10小时就收20元) TariffOfGuanZhou tt = new TariffOfGuanZhou(); tt.DayTimezone = new TariffTimeZone(new TimeEntity(8, 0), new TimeEntity(18, 0), new ChargeUnit(60, 3)); tt.NightTimezone = new TariffTimeZone(new TimeEntity(18, 0), new TimeEntity(8, 0), new ChargeUnit(720, 10)); tt.FreeMinutes = 15; //没有每24小时限额 Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 9, 12, 16, 0)) == 3); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 9, 18, 0, 0)) == 21); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 9, 18, 1, 0)) == 31); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 10, 8, 0, 0)) == 41); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 10, 8, 2, 0)) == 44); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 10, 11, 16, 0)) == 53); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 10, 11, 18, 0)) == 53); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 10, 18, 0, 0)) == 71); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 10, 18, 1, 0)) == 81); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 11, 8, 0, 0)) == 91); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 11, 8, 2, 0)) == 94); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 11, 11, 16, 0)) == 103); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 11, 11, 18, 0)) == 103); tt.FeeOf24Hour = 40; //每24小时限额40元 Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 9, 12, 16, 0)) == 3); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 9, 18, 0, 0)) == 21); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 9, 18, 1, 0)) == 31); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 10, 8, 0, 0)) == 40); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 10, 8, 2, 0)) == 40); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 10, 11, 16, 0)) == 40); //从下面三个可以看出每24小时到点后重新开始收 Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 10, 11, 18, 0)) == 43); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 10, 12, 16, 0)) == 43); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 10, 12, 17, 0)) == 46); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 10, 18, 0, 0)) == 61); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 10, 18, 1, 0)) == 71); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 11, 8, 0, 0)) == 80); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 11, 8, 2, 0)) == 80); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 11, 11, 16, 0)) == 80); Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 9, 11, 16, 0), new DateTime(2011, 3, 11, 11, 18, 0)) == 83); }
public void TariffOfGuanZhouDiscountTest() { //太古汇收费时段入场免费30分钟,8:00-22:00 每15分钟收4元,22:00-8:00 每15分钟收1元 最高限价10元,24小时最高收费128元 TariffOfGuanZhou tt = new TariffOfGuanZhou(); tt.FreeMinutes = 30; tt.DayTimezone = new TariffTimeZone(new TimeEntity(8, 0), new TimeEntity(22, 0), new ChargeUnit(15, 4)); tt.NightTimezone = new TariffTimeZone(new TimeEntity(22, 0), new TimeEntity(8, 0), new ChargeUnit(15, 1)); tt.NightTimezone.LimiteFee = 10; tt.FeeOf24Hour = 128; int curHour = 0; //第一条为费用,第二条为优惠金额,第三条为使用优惠时数 Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 15, 12, 04), new DateTime(2014, 9, 12, 18, 23, 03)) == 180); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 15, 12, 04), new DateTime(2014, 9, 12, 18, 23, 03), 3, out curHour) == 48); Assert.IsTrue(curHour == 3); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 15, 12, 04), new DateTime(2014, 9, 12, 15, 15, 53)) == 132); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 15, 12, 04), new DateTime(2014, 9, 12, 15, 15, 53), 1, out curHour) == 4); Assert.IsTrue(curHour == 1); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 19, 15, 48, 47), new DateTime(2014, 9, 19, 17, 03, 12)) == 20); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 19, 15, 48, 47), new DateTime(2014, 9, 19, 17, 03, 12), 1, out curHour) == 16); Assert.IsTrue(curHour == 1); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 11, 10, 07, 00)) == 46); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 11, 10, 07, 00), 3, out curHour) == 36); Assert.IsTrue(curHour == 3); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 07, 04, 27), new DateTime(2014, 9, 11, 12, 55, 16)) == 84); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 07, 04, 27), new DateTime(2014, 9, 11, 12, 55, 16), 3, out curHour) == 48); Assert.IsTrue(curHour == 3); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 07, 04, 27), new DateTime(2014, 9, 11, 09, 50, 08)) == 36); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 07, 04, 27), new DateTime(2014, 9, 11, 09, 50, 08), 3, out curHour) == 36); Assert.IsTrue(curHour == 3); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 07, 04, 27), new DateTime(2014, 9, 12, 06, 02, 42)) == 128); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 07, 04, 27), new DateTime(2014, 9, 12, 06, 02, 42), 3, out curHour) == 0); Assert.IsTrue(curHour == 3); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 07, 04, 27), new DateTime(2014, 9, 12, 12, 04, 29)) == 200); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 07, 04, 27), new DateTime(2014, 9, 12, 12, 04, 29), 3, out curHour) == 48); Assert.IsTrue(curHour == 3); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 07, 04, 27), new DateTime(2014, 9, 12, 06, 10, 06)) == 128); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 07, 04, 27), new DateTime(2014, 9, 12, 06, 10, 06), 3, out curHour) == 0); Assert.IsTrue(curHour == 3); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 07, 04, 27), new DateTime(2014, 9, 12, 03, 10, 12)) == 128); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 07, 04, 27), new DateTime(2014, 9, 12, 03, 10, 12), 3, out curHour) == 0); Assert.IsTrue(curHour == 3); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 11, 12, 07, 48)) == 78); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 11, 12, 07, 48), 3, out curHour) == 48); Assert.IsTrue(curHour == 3); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 12, 09, 08, 54)) == 158); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 12, 09, 08, 54), 3, out curHour) == 22); Assert.IsTrue(curHour == 3); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 12, 09, 08, 54)) == 158); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 12, 09, 08, 54), 2, out curHour) == 20); Assert.IsTrue(curHour == 2); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 12, 12, 10, 14)) == 206); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 12, 12, 10, 14), 3, out curHour) == 48); Assert.IsTrue(curHour == 3); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 12, 03, 09, 25)) == 128); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 12, 03, 09, 25), 3, out curHour) == 0); Assert.IsTrue(curHour == 3); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 21, 05, 06, 08)) == 1285); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 21, 05, 06, 08), 3, out curHour) == 5); Assert.IsTrue(curHour == 3); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 21, 08, 06, 08)) == 1294); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 21, 08, 06, 08), 3, out curHour) == 10); Assert.IsTrue(curHour == 3); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 21, 05, 06, 08)) == 1285); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 21, 05, 06, 08), 27, out curHour) == 133); Assert.IsTrue(curHour == 27); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 21, 08, 06, 08)) == 1294); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 21, 08, 06, 08), 27, out curHour) == 138); Assert.IsTrue(curHour == 27); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 21, 10, 00), new DateTime(2014, 9, 11, 22, 09, 00)) == 17); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 21, 10, 00), new DateTime(2014, 9, 11, 22, 09, 00), 1, out curHour) == 17); Assert.IsTrue(curHour == 1); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 21, 28, 00), new DateTime(2014, 9, 11, 22, 27, 00)) == 14); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 21, 28, 00), new DateTime(2014, 9, 11, 22, 27, 00), 1, out curHour) == 14); Assert.IsTrue(curHour == 1); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 18, 10, 00), new DateTime(2014, 9, 11, 22, 11, 00)) == 65); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 18, 10, 00), new DateTime(2014, 9, 11, 22, 11, 00), 3, out curHour) == 49); Assert.IsTrue(curHour == 3); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 21, 28, 00), new DateTime(2014, 9, 11, 22, 29, 00)) == 14); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 21, 28, 00), new DateTime(2014, 9, 11, 22, 29, 00), 1, out curHour) == 14); Assert.IsTrue(curHour == 1); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 21, 05, 06, 08)) == 1285); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 21, 05, 06, 08), 23, out curHour) == 123); Assert.IsTrue(curHour == 23); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 21, 08, 06, 08)) == 1294); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 11, 04, 05, 08), new DateTime(2014, 9, 21, 08, 06, 08), 23, out curHour) == 132); Assert.IsTrue(curHour == 23); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 19, 21, 34, 35), new DateTime(2014, 9, 20, 19, 35, 01)) == 128); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 19, 21, 34, 35), new DateTime(2014, 9, 20, 19, 35, 01), 20, out curHour) == 120); Assert.IsTrue(curHour == 20); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 9, 18, 07, 32, 10), new DateTime(2014, 9, 19, 08, 33, 06)) == 142); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 9, 18, 07, 32, 10), new DateTime(2014, 9, 19, 08, 33, 06), 20, out curHour) == 132); Assert.IsTrue(curHour == 20); Assert.IsTrue(tt.CalculateFee(new DateTime(2014, 11, 05, 21, 35, 51), new DateTime(2014, 11, 06, 14, 56, 48)) == 128); Assert.IsTrue(tt.CalculateDiscountFee(new DateTime(2014, 11, 05, 21, 35, 51), new DateTime(2014, 11, 06, 14, 56, 48), 3, out curHour) == 46); Assert.IsTrue(curHour == 3); }