コード例 #1
0
ファイル: RateIdentifier.cs プロジェクト: DivasGulati/CarPark
        private bool EvaluateWeekend(Visit visit)
        {
            var      duration      = visit.GetDuration();
            DateTime mondayMorning = default(DateTime);
            var      result        = false;


            if (visit.Entry.DayOfWeek == DayOfWeek.Saturday)
            {
                mondayMorning = EvaluateWeekend_Helper(visit, 2);
            }
            else if (visit.Entry.DayOfWeek == DayOfWeek.Sunday)
            {
                mondayMorning = EvaluateWeekend_Helper(visit, 1);
            }
            else
            {
                return(false);
            }


            if (visit.Exit <= mondayMorning)
            {
                result = true;
            }

            return(result);
        }
コード例 #2
0
        public void CorrectlyReturnsSpecifiedVisit()
        {
            Visit visit = dr.GetVisit(vis.Id);

            Assert.AreEqual(vis.Id, visit.Id);
            Assert.AreEqual(1, visit.VehicleId);
            Assert.AreEqual(2, visit.GetDuration());
        }
コード例 #3
0
ファイル: RateIdentifier.cs プロジェクト: DivasGulati/CarPark
        private bool EvaluateEarlyBird(Visit visit)
        {
            var duration = visit.GetDuration();

            TimeSpan ebEntryCondtion1 = new TimeSpan(6, 0, 0);   //10 o'clock
            TimeSpan ebEntryCondtion2 = new TimeSpan(9, 0, 0);   //12 o'clock
            TimeSpan ebExitCondition1 = new TimeSpan(15, 30, 0); //10 o'clock
            TimeSpan ebExitCondition2 = new TimeSpan(23, 30, 0); //12 o'clock

            return(visit.Entry.TimeOfDay >= ebEntryCondtion1 && visit.Entry.TimeOfDay <= ebEntryCondtion2 &&
                   visit.Exit.TimeOfDay >= ebExitCondition1 && visit.Exit.TimeOfDay <= ebExitCondition2 &&
                   duration <= new TimeSpan(23, 59, 59) && visit.Entry.Day == visit.Exit.Day);
        }
コード例 #4
0
ファイル: RateIdentifier.cs プロジェクト: DivasGulati/CarPark
        private bool EvaluateNight(Visit visit)
        {
            var duration = visit.GetDuration();

            var nextDaySixAmTime = new DateTime(visit.Entry.Year, visit.Entry.Month, visit.Entry.Day, 6, 0, 0).AddDays(1);


            TimeSpan nEntryCondtion1 = new TimeSpan(18, 0, 0); //10 o'clock
            TimeSpan nEntryCondtion2 = new TimeSpan(24, 0, 0); //12 o'clock
            TimeSpan nExitCondition1 = new TimeSpan(6, 0, 0);  //10 o'clock

            return(visit.Entry.TimeOfDay >= nEntryCondtion1 &&
                   visit.Exit <= nextDaySixAmTime &&
                   (visit.Entry.DayOfWeek != DayOfWeek.Saturday && visit.Entry.DayOfWeek != DayOfWeek.Sunday));
        }
コード例 #5
0
        public override double Calculate(Visit visit)
        {
            var    duration = visit.GetDuration();
            double rate     = 0.0;

            if (visit.Entry.Day == visit.Exit.Day && duration <= new TimeSpan(24, 0, 0)) // same day visit
            {
                rate = GetRate(duration);
            }
            else // more than 1 day visit
            {
                var sameDayStartOfDay = new DateTime(visit.Exit.Year, visit.Exit.Month, visit.Exit.Day);
                rate = _rateMap[HourlyRateType.ThreePlusHours] * duration.Days + GetRate(visit.Exit.Subtract(sameDayStartOfDay));
            }

            return(rate);
        }
コード例 #6
0
        public void CorrectlyReturnsDuration()
        {
            var now = DateTimeOffset.Now;

            Assert.AreEqual(5, visit.GetDuration());
        }