public void RaceInformationTest() { //Arrange var extractService = new ExtractDataFake(); var computeService = new ComputeRankingKartRaceService(); var outputService = new OutputKartRaceInformationService(); //Act KartRaceInformation raceInfo = new KartRaceInformation(extractService, computeService, outputService); raceInfo.ExtractDataFromFile("bazinga.txt"); raceInfo.ComputeRanking(); raceInfo.GetBestLap(); raceInfo.PrintOutput(); //Assert Assert.AreEqual(raceInfo.Laps.Count, 4); Assert.AreEqual(raceInfo.Ranking.Count, 2); Assert.AreEqual(raceInfo.Ranking[0].PilotCode, "001"); Assert.AreEqual(raceInfo.Ranking[0].PilotName, "Pilot 1"); Assert.AreEqual(raceInfo.Ranking[0].BestLapNumber, 2); Assert.AreEqual(raceInfo.Ranking[1].PilotCode, "002"); Assert.AreEqual(raceInfo.Ranking[1].PilotName, "Pilot 2"); Assert.AreEqual(raceInfo.Ranking[1].BestLapNumber, 1); Assert.AreEqual(raceInfo.BestLap.PilotCode, "001"); Assert.AreEqual(raceInfo.BestLap.PilotName, "Pilot 1"); Assert.AreEqual(raceInfo.BestLap.BestLapNumber, 2); }
static void Main(string[] args) { var dataParser = new DataExtractedParser(); var positionalExtractorService = new PositionalDataLineExtrator <KartLap>(dataParser); var extractService = new ExtractKartRaceFileService(positionalExtractorService); var computeService = new ComputeRankingKartRaceService(); var outputService = new OutputKartRaceInformationService(); KartRaceInformation raceInfo = new KartRaceInformation(extractService, computeService, outputService); raceInfo.ExtractDataFromFile("data.txt"); raceInfo.ComputeRanking(); raceInfo.GetBestLap(); raceInfo.PrintOutput(); Console.WriteLine("\nPress any key to exit"); Console.ReadKey(); }