public void ImportParticpantsWithClassAssignment() { string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"TestDB_EmptyManyClasses.mdb"); RaceHorologyLib.Database db = new RaceHorologyLib.Database(); db.Connect(dbFilename); AppDataModel dm = new AppDataModel(db); var ir = new ImportReader(@"Teilnehmer_V1_202001301844.csv"); RaceMapping mapping = new RaceMapping(ir.Columns); ClassAssignment cla = new ClassAssignment(dm.GetParticipantClasses()); RaceImport im = new RaceImport(dm.GetRace(0), mapping, cla); var impRes = im.DoImport(ir.Data); Assert.AreEqual(153, impRes.SuccessCount); Assert.AreEqual(0, impRes.ErrorCount); for (int i = 0; i < 153; i++) { Participant p = dm.GetParticipants()[i]; RaceParticipant rp = dm.GetRace(0).GetParticipants()[i]; Assert.AreEqual(string.Format("Name {0}", i + 1), p.Name); Assert.AreEqual(string.Format("Name {0}", i + 1), rp.Name); Assert.IsTrue(rp.Participant == p); Assert.AreSame(cla.DetermineClass(p), p.Class); Assert.IsNotNull(p.Class); } }
public void ImportParticpantsForRaceWithPoints() { TestDataGenerator tg = new TestDataGenerator(); var ir = new ImportReader(@"Teilnehmer_Import_Race.xlsx"); RaceMapping mapping = new RaceMapping(ir.Columns); RaceImport im = new RaceImport(tg.Model.GetRace(0), mapping); var impRes = im.DoImport(ir.Data); Assert.AreEqual(20, impRes.SuccessCount); Assert.AreEqual(0, impRes.ErrorCount); for (int i = 0; i < 20; i++) { Participant p = tg.Model.GetParticipants()[i]; RaceParticipant rp = tg.Model.GetRace(0).GetParticipants()[i]; Assert.AreEqual(string.Format("Name {0}", i + 1), p.Name); Assert.AreEqual(string.Format("Name {0}", i + 1), rp.Name); if (i == 0) { Assert.AreEqual((double)(1), rp.Points); } else if (i == 1) { Assert.AreEqual((double)(2), rp.Points); } else if (i == 2) { Assert.AreEqual((double)(3.3), rp.Points); } else if (i == 3) { Assert.AreEqual((double)(-1), rp.Points); } else { Assert.AreEqual((double)(i + 1), rp.Points); } if (i == 3) { Assert.AreEqual((uint)(0), rp.StartNumber); } else { Assert.AreEqual((uint)(20 - i), rp.StartNumber); } Assert.IsTrue(rp.Participant == p); } }
public void ImportParticpantsForRaceViaZip() { string[] columnShall = { "id", "nachname", "vorname", "geschlecht", "verein", "verbandskürzel", "jg", "punkte", "adr_str", "adr_plz", "adr_ort" }; void checkColumns(List <string> columns) { for (int i = 0; i < columnShall.Length; i++) { Assert.AreEqual(columnShall[i], columns[i]); } } TestDataGenerator tg = new TestDataGenerator(); var ir = new ImportZipReader(@"1557MRBR.zip"); checkColumns(ir.Columns); RaceMapping mapping = new RaceMapping(ir.Columns); RaceImport im = new RaceImport(tg.Model.GetRace(0), mapping); var impRes = im.DoImport(ir.Data); Assert.AreEqual(3, impRes.SuccessCount); Assert.AreEqual(0, impRes.ErrorCount); Assert.AreEqual(3, ir.Data.Tables[0].Rows.Count); for (int i = 0; i < 2; i++) { Participant p = tg.Model.GetParticipants()[i]; RaceParticipant rp = tg.Model.GetRace(0).GetParticipants()[i]; Assert.AreEqual(string.Format("NACHNAME{0}", i + 1), p.Name); Assert.AreEqual(string.Format("Vorname{0}", i + 1), rp.Firstname); Assert.IsTrue(rp.Participant == p); } }
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(); }
public void ImportParticpantsForRace() { TestDataGenerator tg = new TestDataGenerator(); var ir = new ImportReader(@"Teilnehmer_V1_202001301844.csv"); RaceMapping mapping = new RaceMapping(ir.Columns); RaceImport im = new RaceImport(tg.Model.GetRace(0), mapping); var impRes = im.DoImport(ir.Data); Assert.AreEqual(153, impRes.SuccessCount); Assert.AreEqual(0, impRes.ErrorCount); for (int i = 0; i < 153; i++) { Participant p = tg.Model.GetParticipants()[i]; RaceParticipant rp = tg.Model.GetRace(0).GetParticipants()[i]; Assert.AreEqual(string.Format("Name {0}", i + 1), p.Name); Assert.AreEqual(string.Format("Name {0}", i + 1), rp.Name); Assert.IsTrue(rp.Participant == p); } }