public void LoadDefaultModel() { _driverRepository.AddDriver(new Driver(16, "Charles", "Leclerc")); _driverRepository.AddDriver(new Driver(5, "Sebastian", "Vettel")); _driverRepository.AddDriver(new Driver(44, "Lewis", "Hamilton")); _driverRepository.AddDriver(new Driver(77, "Valteri", "Bottas")); _driverRepository.AddDriver(new Driver(3, "Max", "Verstapen")); _driverRepository.AddDriver(new Driver(55, "Carlos", "Seinz")); _trackRepository.AddTrack(new Track(_trackRepository.GetNewID(), "Melbourne Grand Prix Circuit", "Australia", 5303000)); _trackRepository.AddTrack(new Track(_trackRepository.GetNewID(), "Bahrein International Circuit", "Bahrein", 5412000)); _trackRepository.AddTrack(new Track(_trackRepository.GetNewID(), "Spa-Francorchhamps", "Belgium", 7004000)); _trackRepository.AddTrack(new Track(_trackRepository.GetNewID(), "Shangai International Circuit", "China", 5451000)); _trackRepository.AddTrack(new Track(_trackRepository.GetNewID(), "Hanoi Circuit", "Vietnam", 5607000)); _raceRepository.AddRace(new Race(_raceRepository.GetNewID(), "Australia GP", new DateTime(2020, 3, 15), _trackRepository.GetTrackByName("Melbourne Grand Prix Circuit"))); _raceRepository.AddRace(new Race(_raceRepository.GetNewID(), "Bahrein GP", new DateTime(2020, 3, 22), _trackRepository.GetTrackByName("Bahrein International Circuit"))); _raceRepository.AddRace(new Race(_raceRepository.GetNewID(), "Vietnam GP", new DateTime(2020, 4, 5), _trackRepository.GetTrackByName("Hanoi Circuit"))); _raceRepository.AddRace(new Race(_raceRepository.GetNewID(), "China GP", new DateTime(2020, 4, 19), _trackRepository.GetTrackByName("Shangai International Circuit"))); RaceResults raceResults = new RaceResults(_driverRepository.GetAllActiveDrivers(), _driverRepository.GetDriverByGoKart(16)); _raceRepository.EnterResults("Australia GP", raceResults); _driverRepository.AddPoints(16, 26); _driverRepository.AddPoints(5, 18); _driverRepository.AddPoints(44, 15); _driverRepository.AddPoints(77, 12); _driverRepository.AddPoints(3, 10); _driverRepository.AddPoints(55, 8); }
public void Test_AddingSameRaceReferenceTwice() { RaceRepository raceRepository = RaceRepository.GetInstance(); Race race = new Race(raceRepository.GetNewID(), "BahGP", new DateTime(2020, 3, 22), trackRepository.GetTrackByName("Bahrein International Circuit")); raceRepository.AddRace(race); raceRepository.AddRace(race); }
public void Test_AddTwoRacesWithSameName() { RaceRepository raceRepository = RaceRepository.GetInstance(); Race race1 = new Race(raceRepository.GetNewID(), "BahGP", new DateTime(2020, 3, 22), trackRepository.GetTrackByName("Bahrein International Circuit")); Race race2 = new Race(raceRepository.GetNewID(), "BahGP", new DateTime(2020, 3, 15), trackRepository.GetTrackByName("Melbourne Grand Prix Circuit")); raceRepository.AddRace(race1); raceRepository.AddRace(race2); }
public void Test_AddRace() { RaceRepository raceRepository = RaceRepository.GetInstance(); Race race = new Race(raceRepository.GetNewID(), "AusGP", new DateTime(2020, 3, 15), trackRepository.GetTrackByName("Melbourne Grand Prix Circuit")); raceRepository.AddRace(race); Race getRace = raceRepository.GetRaceByName("AusGP"); Assert.IsInstanceOfType(getRace, typeof(Race)); }
public void Test_EnterRaceResults() { RaceRepository raceRepository = RaceRepository.GetInstance(); Race race = new Race(raceRepository.GetNewID(), "AusGP", new DateTime(2020, 3, 15), trackRepository.GetTrackByName("Melbourne Grand Prix Circuit")); raceRepository.AddRace(race); RaceResults raceResults = new RaceResults(driverRepository.GetAllActiveDrivers(), driverRepository.GetDriverByGoKart(16)); raceRepository.EnterResults("AusGP", raceResults); Assert.IsTrue(raceRepository.GetRaceByName("AusGP").Finished); }
public void Test_EditRace() { RaceRepository raceRepository = RaceRepository.GetInstance(); Race race = new Race(raceRepository.GetNewID(), "AusGP", new DateTime(2020, 3, 15), trackRepository.GetTrackByName("Melbourne Grand Prix Circuit")); raceRepository.AddRace(race); raceRepository.UpdateRace(race.ID, "Nova utrka", new DateTime(2903, 1, 23), trackRepository.GetTrackByName("Bahrein International Circuit")); Race update = raceRepository.GetRaceByName("Nova utrka"); Assert.AreEqual("Bahrein", update.Track.Location); }
public void Test_TryToRemoveFinishedRace() { RaceRepository raceRepository = RaceRepository.GetInstance(); Race race = new Race(raceRepository.GetNewID(), "BelGP", new DateTime(2020, 3, 22), trackRepository.GetTrackByName("Spa-Francorchhamps")); raceRepository.AddRace(race); RaceResults raceResults = new RaceResults(driverRepository.GetAllActiveDrivers(), driverRepository.GetDriverByGoKart(5)); raceRepository.EnterResults("BelGP", raceResults); raceRepository.RemoveRace(raceRepository.GetRaceByName("BelGP")); }
public void AddRace(IAddRaceView inForm) { RaceRepository raceRepository = RaceRepository.GetInstance(); TrackRepository trackRepository = TrackRepository.GetInstance(); if (inForm.ShowViewModal(trackRepository.GetAllActiveTracks()) == true) { try { string Name = inForm.RaceName; if (string.IsNullOrEmpty(Name)) { throw new ArgumentException("Race name is not selected!"); } DateTime Date = inForm.RaceDate; if (Date < DateTime.Today) { throw new ArgumentException("Selected date is in the past!"); } string RaceTrackName = inForm.RaceTrackName; if (string.IsNullOrEmpty(RaceTrackName)) { throw new ArgumentException("Track name is not properly selected!"); } Track RaceTrack = trackRepository.GetTrackByName(RaceTrackName); int ID = raceRepository.GetNewID(); Race newRace = RaceFactory.CreateRace(ID, Name, Date, RaceTrack); raceRepository.AddRace(newRace); } catch (TrackNotFoundException) { MessageBox.Show("Selected track not found! Try again."); } catch (RaceAlreadyExistsException) { MessageBox.Show("Race already exists! Try again."); } catch (ArgumentException ex) { MessageBox.Show(ex.Message + " Try again."); } } }
public void Test_GetDriverWithFastestLapInRace() { RaceRepository raceRepository = RaceRepository.GetInstance(); Race race = new Race(raceRepository.GetNewID(), "BahGP", new DateTime(2020, 3, 22), trackRepository.GetTrackByName("Bahrein International Circuit")); raceRepository.AddRace(race); RaceResults raceResults = new RaceResults(driverRepository.GetAllActiveDrivers(), driverRepository.GetDriverByGoKart(5)); raceRepository.EnterResults("BahGP", raceResults); Race getRace = raceRepository.GetRaceByName("BahGP"); Assert.AreEqual(5, getRace.Results.FastestLap.GoKart); }
public ActionResult <Race> PostRace(int year) { var race = _raceRepository.AddRace(year); return(CreatedAtAction("GetRace", new { id = race.Id }, race)); }