public void Race_ManageRun() { TestDataGenerator tg = new TestDataGenerator(); var dm = new AppDataModel(new DummyDataBase(".", false)); // Create empty model Assert.AreEqual(0, dm.GetRaces().Count); dm.AddRace(new Race.RaceProperties { RaceType = Race.ERaceType.GiantSlalom, Runs = 1 }); Assert.AreEqual(1, dm.GetRaces().Count); Race race = dm.GetRace(0); Assert.AreEqual(1, race.GetMaxRun()); Assert.IsNull(race.GetPreviousRun(null)); Assert.IsNull(race.GetPreviousRun(race.GetRun(0))); race.AddRaceRun(); Assert.AreEqual(2, race.GetMaxRun()); Assert.IsNull(race.GetPreviousRun(null)); Assert.IsNull(race.GetPreviousRun(race.GetRun(0))); Assert.AreEqual(race.GetRun(0), race.GetPreviousRun(race.GetRun(1))); race.DeleteRaceRun(); Assert.AreEqual(1, race.GetMaxRun()); race.UpdateNumberOfRuns(3); Assert.AreEqual(3, race.GetMaxRun()); Assert.IsNull(race.GetPreviousRun(null)); Assert.IsNull(race.GetPreviousRun(race.GetRun(0))); Assert.AreEqual(race.GetRun(0), race.GetPreviousRun(race.GetRun(1))); Assert.AreEqual(race.GetRun(1), race.GetPreviousRun(race.GetRun(2))); race.UpdateNumberOfRuns(2); Assert.AreEqual(2, race.GetMaxRun()); Assert.IsNull(race.GetPreviousRun(null)); Assert.IsNull(race.GetPreviousRun(race.GetRun(0))); Assert.AreEqual(race.GetRun(0), race.GetPreviousRun(race.GetRun(1))); }