コード例 #1
0
        public void TeamCountsFourRunnersThreeTeams()
        {
            TestRunners = LoadFourRunnersFromThreeTeams();
            RaceField Field = new RaceField(string.Empty, 5, 7);

            TestRunners.ForEach(x => Field.AddRunner(x));
            int oneRunner  = 0;
            int twoRunners = 0;

            foreach (var fieldTeamCount in Field.TeamCounts)
            {
                if (fieldTeamCount.Value == 1)
                {
                    oneRunner++;
                }

                if (fieldTeamCount.Value == 2)
                {
                    twoRunners++;
                }
            }
            Assert.AreEqual(3, Field.TeamCounts.Count);
            Assert.AreEqual(1, twoRunners);
            Assert.AreEqual(2, oneRunner);
        }
コード例 #2
0
ファイル: RaceService.cs プロジェクト: mattliuoz/test
        public async Task <RaceResult> GetRaceResult(RaceField raceField)
        {
            var connector  = _raceDataConnectorService.GetDataConnector(raceField);
            var raceResult = await connector.GetRaceResult();

            return(raceResult);
        }
コード例 #3
0
        public void TeamWithTooFewDontCountTwpRunners()
        {
            TestRunners = LoadSixRunnersFromFourTeams();
            RaceField Field = new RaceField(string.Empty, 2, 7);

            TestRunners.ForEach(x => Field.AddRunner(x));
            Field.AssignPoints();
            Runner lastRunner = Field.Runners[5];

            Assert.AreEqual(4, lastRunner.Points);
            Assert.AreEqual(6, lastRunner.Place);
        }
コード例 #4
0
        public void TeamWithTooFewDontCountOneRunner()
        {
            TestRunners = LoadFiveRunnersFromThreeTeams();
            RaceField Field = new RaceField(string.Empty, 2, 7);

            TestRunners.ForEach(x => Field.AddRunner(x));
            Field.AssignPoints();
            Runner lastRunner = Field.Runners[4];

            Assert.AreEqual(4, lastRunner.Points);
            Assert.AreEqual(5, lastRunner.Place);
        }
コード例 #5
0
        public void TeamCountsFourRunnersFourTeams()
        {
            TestRunners = LoadFourRunnersFromFourTeams();
            RaceField Field = new RaceField(string.Empty, 5, 7);

            TestRunners.ForEach(x => Field.AddRunner(x));
            Assert.AreEqual(4, Field.TeamCounts.Count);
            foreach (var fieldTeamCount in Field.TeamCounts)
            {
                Assert.AreEqual(1, fieldTeamCount.Value);
            }
        }
コード例 #6
0
        public RaceDataConnector GetDataConnector(RaceField raceField)
        {
            if (raceField == RaceField.Caulfield)
            {
                return(new CaulfieldRaceDataConnector(_config.Value));
            }

            if (raceField == RaceField.Wolferhampton)
            {
                return(new WolferhamptonRaceDataConnector(_config.Value));
            }

            throw new NotSupportedException($"{raceField.ToString()} does not have any data connector.");
        }