예제 #1
0
        public void CompareTo_ShouldConsiderDNFSlower()
        {
            Beacon martijnBeacon = new Beacon(new byte[] { 0, 0, 0, 0, 0, 1 }, 2);
            Rider  martijn       = new Rider("Martijn", martijnBeacon);

            //make a regular lap
            IdEvent     startId     = new IdEvent(DateTime.Now, martijn, "StartId", Direction.Enter);
            TimingEvent startTiming = new TimingEvent(DateTime.Now, martijn, 100, 0);
            IdEvent     endId       = new IdEvent(DateTime.Now, martijn, "EndId", Direction.Enter);
            TimingEvent endTiming   = new TimingEvent(DateTime.Now, martijn, 200, 1);

            FinishedEvent finish = new FinishedEvent(startId, startTiming, endTiming, endId);

            Lap normalLap = new Lap(finish);

            //make a DNF lap
            IdEvent dnfStartId = new IdEvent(DateTime.Now, martijn, "StartId", Direction.Enter);

            ManualDNFEvent manualDnf = new ManualDNFEvent(dnfStartId, "staff");
            UnitDNFEvent   unitDnf   = new UnitDNFEvent(finish, dnfStartId);

            Lap manualDnfLap = new Lap(manualDnf);
            Lap unitDnfLap   = new Lap(unitDnf);

            //a dnf lap should always be slower (bigger) than a finished lap
            Assert.AreEqual(1, manualDnfLap.CompareTo(normalLap));
            Assert.AreEqual(-1, normalLap.CompareTo(manualDnfLap));

            Assert.AreEqual(1, unitDnfLap.CompareTo(normalLap));
            Assert.AreEqual(-1, normalLap.CompareTo(unitDnfLap));

            //dnf laps have no mutual ordering
            Assert.AreEqual(1, manualDnfLap.CompareTo(unitDnfLap));
            Assert.AreEqual(1, unitDnfLap.CompareTo(manualDnfLap));
        }
예제 #2
0
        public void RaceWithMultipleOnTrack_AndDNF_ShouldWork()
        {
            SimulateRaceWithDNF();

            source.Cancel();
            RaceSummary summary = race.Result;
            var         state   = subject.GetState;

            List <FinishedEvent> finishes = summary.Events.Where(e => e is FinishedEvent).Select(e => e as FinishedEvent).ToList();
            UnitDNFEvent         dnf      = summary.Events.Last() as UnitDNFEvent;

            Assert.AreEqual("Martijn", finishes[0].Rider.Name);
            Assert.AreEqual("Bert", finishes[1].Rider.Name);

            Assert.AreEqual("Richard", dnf.Rider.Name);
            Assert.AreEqual("Bert", dnf.OtherRider.Rider.Name);

            //There should be nothing going on in the race at this point
            Assert.AreEqual(0, state.waiting.Count);
            Assert.AreEqual(0, state.unmatchedIds.Count);
            Assert.AreEqual(0, state.onTrack.Count);
            Assert.AreEqual(0, state.unmatchedTimes.Count);
        }