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 ClassAssignmentTest() { List <ParticipantClass> classes = new List <ParticipantClass>(); classes.Add(new ParticipantClass("1M", null, "Class1", new ParticipantCategory('M'), 2009, 1)); classes.Add(new ParticipantClass("1W", null, "Class1", new ParticipantCategory('W'), 2009, 2)); classes.Add(new ParticipantClass("2M", null, "Class1", new ParticipantCategory('M'), 2011, 3)); classes.Add(new ParticipantClass("2W", null, "Class1", new ParticipantCategory('W'), 2011, 4)); Participant p2008M = new Participant { Year = 2008, Sex = new ParticipantCategory('M') }; Participant p2008W = new Participant { Year = 2008, Sex = new ParticipantCategory('W') }; Participant p2009M = new Participant { Year = 2009, Sex = new ParticipantCategory('M') }; Participant p2009W = new Participant { Year = 2009, Sex = new ParticipantCategory('W') }; Participant p2010M = new Participant { Year = 2010, Sex = new ParticipantCategory('M') }; Participant p2010W = new Participant { Year = 2010, Sex = new ParticipantCategory('W') }; Participant p2011M = new Participant { Year = 2011, Sex = new ParticipantCategory('M') }; Participant p2011W = new Participant { Year = 2011, Sex = new ParticipantCategory('W') }; Participant p2012M = new Participant { Year = 2012, Sex = new ParticipantCategory('M') }; Participant p2012W = new Participant { Year = 2012, Sex = new ParticipantCategory('W') }; ClassAssignment ca = new ClassAssignment(classes); // Test ClassAssignment.DetermineClass Assert.AreEqual("1M", ca.DetermineClass(p2008M).Id); Assert.AreEqual("1W", ca.DetermineClass(p2008W).Id); Assert.AreEqual("1M", ca.DetermineClass(p2009M).Id); Assert.AreEqual("1W", ca.DetermineClass(p2009W).Id); Assert.AreEqual("2M", ca.DetermineClass(p2010M).Id); Assert.AreEqual("2W", ca.DetermineClass(p2010W).Id); Assert.AreEqual("2M", ca.DetermineClass(p2011M).Id); Assert.AreEqual("2W", ca.DetermineClass(p2011W).Id); Assert.IsNull(ca.DetermineClass(p2012M)); Assert.IsNull(ca.DetermineClass(p2012W)); // Test ClassAssignment.Assign List <Participant> participants = new List <Participant>(); participants.Add(p2008M); participants.Add(p2008W); participants.Add(p2009M); participants.Add(p2009W); participants.Add(p2010M); participants.Add(p2010W); participants.Add(p2011M); participants.Add(p2011W); participants.Add(p2012M); participants.Add(p2012W); ca.Assign(participants); foreach (var p in participants) { Assert.AreEqual(ca.DetermineClass(p), p.Class); } }