Пример #1
0
 private void BtnExportDsvAlpin_Click(object sender, RoutedEventArgs e)
 {
     exportToTextFile
         ("DSVAlpin - Tab Separated Text File (.txt)|*.txt|" +
         "DSVAlpin - Tab Separated Text File - UTF-8 (.txt)|*.txt"
         , ".txt",
         (Race race, string filePath, bool utf8) =>
     {
         DSVAlpinExport exp = new DSVAlpinExport(race);
         TsvExport tsvExp   = new TsvExport();
         tsvExp.Export(filePath, exp.ExportToDataSet(), utf8);
     }
         );
 }
Пример #2
0
        public void DSVAlpinExport()
        {
            TestDataGenerator tg = new TestDataGenerator();

            tg.createCatsClassesGroups();
            Race race = tg.Model.GetRace(0);

            var rp = tg.createRaceParticipant(cat: tg.findCat('M'), cla: tg.findClass("2M (2010)"), points: 1.0); // 1

            rp.Participant.SvId   = "123";
            rp.Participant.Year   = 2010;
            rp.Participant.Nation = "Nation";
            rp.Participant.Club   = "Verein";
            tg.createRaceParticipant(cat: tg.findCat('M'), cla: tg.findClass("2M (2010)"), points: 2.0);
            tg.createRaceParticipant(cat: tg.findCat('M'), cla: tg.findClass("2M (2010)"), points: 3.0);

            tg.createRaceParticipant(cat: tg.findCat('W'), cla: tg.findClass("2W (2010)"), points: 1.5); // 4
            tg.createRaceParticipant(cat: tg.findCat('W'), cla: tg.findClass("2W (2010)"), points: 2.5);
            tg.createRaceParticipant(cat: tg.findCat('W'), cla: tg.findClass("2W (2010)"), points: 3.5); // 6

            RaceRun rr1 = race.GetRun(0);
            RaceRun rr2 = race.GetRun(1);

            rr1.SetStartFinishTime(race.GetParticipant(1), new TimeSpan(8, 0, 0), new TimeSpan(8, 1, 0));
            rr2.SetRunTime(race.GetParticipant(1), new TimeSpan(0, 0, 2, 0, 123));

            rr1.SetRunTime(race.GetParticipant(2), new TimeSpan(0, 1, 1));
            rr1.SetResultCode(race.GetParticipant(3), RunResult.EResultCode.NiZ);

            DSVAlpinExport export = new DSVAlpinExport(tg.Model.GetRace(0));
            DataSet        ds     = export.ExportToDataSet();

            // Check Column Names
            int i = 0;

            Assert.AreEqual("Idnr", ds.Tables[0].Columns[i++].ColumnName);
            Assert.AreEqual("Stnr", ds.Tables[0].Columns[i++].ColumnName);
            Assert.AreEqual("DSV-ID", ds.Tables[0].Columns[i++].ColumnName);
            Assert.AreEqual("Name", ds.Tables[0].Columns[i++].ColumnName);
            Assert.AreEqual("Kateg", ds.Tables[0].Columns[i++].ColumnName);
            Assert.AreEqual("JG", ds.Tables[0].Columns[i++].ColumnName);
            Assert.AreEqual("V/G", ds.Tables[0].Columns[i++].ColumnName);
            Assert.AreEqual("Verein", ds.Tables[0].Columns[i++].ColumnName);
            Assert.AreEqual("LPkte", ds.Tables[0].Columns[i++].ColumnName);
            Assert.AreEqual("Total", ds.Tables[0].Columns[i++].ColumnName);
            Assert.AreEqual("Zeit 1", ds.Tables[0].Columns[i++].ColumnName);
            Assert.AreEqual("Zeit 2", ds.Tables[0].Columns[i++].ColumnName);
            Assert.AreEqual("Klasse", ds.Tables[0].Columns[i++].ColumnName);
            Assert.AreEqual("Gruppe", ds.Tables[0].Columns[i++].ColumnName);
            Assert.AreEqual("RPkte", ds.Tables[0].Columns[i++].ColumnName);

            // Check first participant
            Assert.AreEqual(1U, ds.Tables[0].Rows[0]["Stnr"]);
            Assert.AreEqual("123", ds.Tables[0].Rows[0]["DSV-ID"]);
            Assert.AreEqual("Name 1, Firstname 1", ds.Tables[0].Rows[0]["Name"]);
            Assert.AreEqual("M", ds.Tables[0].Rows[0]["Kateg"]);
            Assert.AreEqual(2010u, ds.Tables[0].Rows[0]["JG"]);
            Assert.AreEqual("Nation", ds.Tables[0].Rows[0]["V/G"]);
            Assert.AreEqual("Verein", ds.Tables[0].Rows[0]["Verein"]);
            Assert.AreEqual("1,00", ds.Tables[0].Rows[0]["LPkte"]);
            Assert.AreEqual("1:00,00", ds.Tables[0].Rows[0]["Total"]); // BestRun => 60.0
            Assert.AreEqual("1:00,00", ds.Tables[0].Rows[0]["Zeit 1"]);
            Assert.AreEqual("2:00,12", ds.Tables[0].Rows[0]["Zeit 2"]);
            Assert.AreEqual("Class 2M (2010)", ds.Tables[0].Rows[0]["Klasse"]);
            Assert.AreEqual("Group 2M", ds.Tables[0].Rows[0]["Gruppe"]);
            Assert.AreEqual("---", ds.Tables[0].Rows[0]["RPkte"]);

            // Participant 3, Run1: NIZ
            Assert.AreEqual("NIZ1", ds.Tables[0].Rows[2]["Total"]);
            Assert.AreEqual("NIZ", ds.Tables[0].Rows[2]["Zeit 1"]);
            Assert.AreEqual(DBNull.Value, ds.Tables[0].Rows[2]["Zeit 2"]);
        }