private AppDataModel createTestDataModel1Race1Run() { AppDataModel dm = new AppDataModel(new DummyDataBase("dummy")); dm.AddRace(new Race.RaceProperties { RaceType = Race.ERaceType.GiantSlalom, Runs = 1 }); return(dm); }
private void btnCreateRace_Click(object sender, RoutedEventArgs e) { if (cmbRaceType.SelectedIndex < 0) { return; } Race.ERaceType rt = (Race.ERaceType)((CBItem)cmbRaceType.SelectedItem).Value; Race.RaceProperties raceProps = new Race.RaceProperties { RaceType = rt, Runs = 2 }; _dm.AddRace(raceProps); }
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))); }
public void ImportRace() { var db = new RaceHorologyLib.Database(); string dbFilename = db.CreateDatabase("new.mdb"); db.Connect(dbFilename); //RaceHorologyLib.IAppDataModelDataBase db = new RaceHorologyLib.DatabaseDummy("./"); AppDataModel dm = new AppDataModel(db); // Create a Race dm.AddRace(new Race.RaceProperties { RaceType = Race.ERaceType.GiantSlalom, Runs = 2 }); ImportResults impRes = new ImportResults(); TimeSpan time = TestUtilities.Time(() => { var ir = new ImportReader(@"Teilnehmer_V1_202001301844.csv"); RaceMapping mapping = new RaceMapping(ir.Columns); RaceImport im = new RaceImport(dm.GetRace(0), mapping); impRes = im.DoImport(ir.Data); }); Assert.AreEqual(153, impRes.SuccessCount); Assert.AreEqual(0, impRes.ErrorCount); Assert.IsTrue(dm.GetParticipants().Count() == 153); Assert.IsTrue(dm.GetRace(0).GetParticipants().Count() == 153); TestContext.WriteLine(string.Format("Import took: {0:0.00} sec", time.TotalSeconds)); Assert.IsTrue(time.TotalSeconds < 4); //db.Close(); }