Ejemplo n.º 1
0
        public void Penalty_WithoutRiderOnTrack_ShouldBeIgnored()
        {
            subject.AddEvent(new PenaltyEventArgs(DateTime.Now, "nope", "staff", "test", 1));

            source.Cancel();
            RaceSummary summary = race.Result;

            //The penalty event is still recorded, but its not applied to any lap
            Assert.AreEqual(1, summary.Events.Count);
            PenaltyEvent penalty = summary.Events[0] as PenaltyEvent;

            Assert.IsNull(penalty.Rider);
            Assert.AreEqual("test", penalty.Reason);
            Assert.AreEqual("staff", penalty.StaffName);
            Assert.AreEqual(1, penalty.Seconds);
        }
Ejemplo n.º 2
0
        public Report Simulate(DateTime target)
        {
            DateTime currentDate = start;
            Report   report      = new Report();

            overpayment = 0;
            generateWithdrawEvents(target);
            if (currentDate > target)
            {
                report.stringReport = "Неверная дата";
                return(report);
            }
            List <Event> eventHistory = new List <Event>();

            months.Clear();
            int pointer = 0;

            for (; currentDate.Date <= target; currentDate = currentDate.AddDays(1))
            {
                PenaltyEvent penaltyEvent = new PenaltyEvent(currentDate);
                penaltyEvent.Apply(this);
                eventHistory.Add(penaltyEvent);
                for (; pointer < events.Count && events[pointer].date <= currentDate; pointer++)
                {
                    eventHistory.Add(events[pointer]);
                    events[pointer].Apply(this);
                }
            }
            foreach (MonthBill bill in months)
            {
                report.totalDepth   += bill.debt;
                report.totalPenalty += bill.penalty;
            }
            if (report.totalDepth == 0 && report.totalPenalty == 0)
            {
                report.totalDepth = -overpayment;
            }
            return(report);
        }