示例#1
0
        public void GlobalRaceConfig_SaveAndLoad()
        {
            string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"TestDB_Empty.mdb");

            RaceHorologyLib.Database db = new RaceHorologyLib.Database();
            db.Connect(dbFilename);
            AppDataModel model = new AppDataModel(db);

            // Default Config
            Assert.AreEqual("Vereinsrennen - BestOfTwo", model.GlobalRaceConfig.Name);

            var testConfig1 = new RaceConfiguration
            {
                Name            = "BaseName",
                Runs            = 2,
                DefaultGrouping = "DefaultG",
                ActiveFields    = new List <string> {
                    "eins", "zwei"
                },
                RaceResultView       = "RaceResultView",
                RaceResultViewParams = new Dictionary <string, object>(),

                Run1_StartistView         = "Run1_StartistView",
                Run1_StartistViewGrouping = "Run1_StartistViewGrouping",
                Run1_StartistViewParams   = new Dictionary <string, object>(),

                Run2_StartistView         = "Run2_StartistView",
                Run2_StartistViewGrouping = "Run2_StartistViewGrouping",
                Run2_StartistViewParams   = new Dictionary <string, object>(),

                LivetimingParams = new Dictionary <string, string> {
                    { "key", "value" }
                },

                ValueF         = 100,
                ValueA         = 200,
                MinimumPenalty = 300
            };

            // Check for PropertyChanged event
            string propertyChanged = null;

            model.PropertyChanged += delegate(object sender, System.ComponentModel.PropertyChangedEventArgs e)
            {
                propertyChanged = e.PropertyName;
            };

            model.GlobalRaceConfig = testConfig1;
            Assert.AreEqual("GlobalRaceConfig", propertyChanged);

            TestUtilities.AreEqualByJson(testConfig1, model.GlobalRaceConfig);
            model.Close();

            // Check saving and loading from in DB
            RaceHorologyLib.Database db2 = new RaceHorologyLib.Database();
            db2.Connect(dbFilename);
            AppDataModel model2 = new AppDataModel(db2);

            TestUtilities.AreEqualByJson(testConfig1, model2.GlobalRaceConfig);
        }
        public void Race_DeactivatedParticipant()
        {
            string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"TestDB_DeactivatedParticipants.mdb");

            RaceHorologyLib.Database db = new RaceHorologyLib.Database();
            db.Connect(dbFilename);

            AppDataModel model = new AppDataModel(db);
            var          race  = model.GetRace(0);

            void verifyParticpants_1()
            {
                Assert.AreEqual(2, model.GetParticipants().Count);
                Assert.AreEqual(1, race.GetParticipants().Count);
                Assert.AreEqual(1, race.GetRun(0).GetResultList().Count);
                Assert.AreEqual("N1", race.GetRun(0).GetResultList()[0].Participant.Name);
            }

            void verifyParticpants_2()
            {
                Assert.AreEqual(2, race.GetParticipants().Count);
                Assert.AreEqual(2, race.GetRun(0).GetResultList().Count);
                {
                    var rr = race.GetRun(0).GetResultList().First((p) => p.Name == "N1");
                    Assert.AreEqual("N1", rr.Participant.Name);
                    Assert.IsNotNull(rr.Runtime);
                }
                {
                    var rr = race.GetRun(0).GetResultList().First((p) => p.Name == "N2");
                    Assert.AreEqual("N2", rr.Participant.Name);
                    Assert.IsNotNull(rr.Runtime);
                }
            }

            verifyParticpants_1();
            // Add the race participant, check whether the time is available
            race.AddParticipant(model.GetParticipants().First((p) => p.Name == "N2"));
            verifyParticpants_2();

            // Remove participant
            race.RemoveParticipant(model.GetParticipants().First((p) => p.Name == "N2"));
            verifyParticpants_1();

            // Re-add/re-enable the race participant, check whether the saved time data is available
            race.AddParticipant(model.GetParticipants().First((p) => p.Name == "N2"));
            verifyParticpants_2();
        }
示例#3
0
        public void GlobalRaceConfig_DSVAlpinImport()
        {
            string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"TestDB_Empty.mdb");

            AppDataModel configDBAndGetModel(CompetitionProperties.ECompetitionType type)
            {
                RaceHorologyLib.Database db = new RaceHorologyLib.Database();
                db.Connect(dbFilename);

                var compProp = db.GetCompetitionProperties();

                compProp.Type = type;
                db.UpdateCompetitionProperties(compProp);

                return(new AppDataModel(db));
            }

            AppDataModel model;

            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.FIS_Women);
            Assert.AreEqual("FIS Rennen - Damen", model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.FIS_Men);
            Assert.AreEqual("FIS Rennen - Herren", model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.DSV_Points);
            Assert.AreEqual("DSV Erwachsene", model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.DSV_NoPoints);
            Assert.AreEqual("DSV Erwachsene", model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.DSV_SchoolPoints);
            Assert.AreEqual("DSV Schüler U14-U16", model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.DSV_SchoolNoPoints);
            Assert.AreEqual("DSV Schüler U14-U16", model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.VersatilityPoints);
            Assert.AreEqual(null, model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.VersatilityNoPoints);
            Assert.AreEqual(null, model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.ClubInternal_BestRun);
            Assert.AreEqual("Vereinsrennen - BestOfTwo", model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.ClubInternal_Sum);
            Assert.AreEqual("Vereinsrennen - Summe", model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.Parallel);
            Assert.AreEqual(null, model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.Sledding_NoPoints);
            Assert.AreEqual(null, model.GlobalRaceConfig.Name);
            model = configDBAndGetModel(CompetitionProperties.ECompetitionType.Sledding_Points);
            Assert.AreEqual(null, model.GlobalRaceConfig.Name);
        }
示例#4
0
        public void JsonConversion()
        {
            string dbFilename = TestUtilities.CreateWorkingFileFrom(testContextInstance.TestDeploymentDir, @"TestDB_LessParticipants.mdb");

            RaceHorologyLib.Database db = new RaceHorologyLib.Database();
            db.Connect(dbFilename);

            AppDataModel dataModel = new AppDataModel(db);
            Race         race      = dataModel.GetCurrentRace();
            RaceRun      rr1       = race.GetRun(0);

            string jsonStart  = RaceHorologyLib.JsonConversion.ConvertStartList(rr1.GetStartList());
            string jsonResult = RaceHorologyLib.JsonConversion.ConvertRunResults(rr1.GetResultView());

            //string jsonStartExpected = @"{""type"":""startlist"",""data"":[{""Id"":""1"",""StartNumber"":1,""Name"":""Nachname 1"",""Firstname"":""Vorname 1"",""Sex"":""W"",""Year"":2009,""Club"":""Verein 1"",""Nation"":""Nation 1"",""Class"":""Mädchen 2009"",""Group"":""U10 weiblich""},{""Id"":""2"",""StartNumber"":2,""Name"":""Nachname 2"",""Firstname"":""Vorname 2"",""Sex"":""M"",""Year"":2013,""Club"":""Verein 2"",""Nation"":""Nation 2"",""Class"":""Buben 2013"",""Group"":""Bambini männlich""},{""Id"":""3"",""StartNumber"":3,""Name"":""Nachname 3"",""Firstname"":""Vorname 3"",""Sex"":""M"",""Year"":2011,""Club"":""Verein 3"",""Nation"":""Nation 3"",""Class"":""Buben 2011"",""Group"":""U8 männlich""},{""Id"":""4"",""StartNumber"":4,""Name"":""Nachname 4"",""Firstname"":""Vorname 4"",""Sex"":""W"",""Year"":2014,""Club"":""Verein 4"",""Nation"":""Nation 4"",""Class"":""Mädchen 2014"",""Group"":""Bambini weiblich""},{""Id"":""5"",""StartNumber"":5,""Name"":""Nachname 5"",""Firstname"":""Vorname 5"",""Sex"":""M"",""Year"":2012,""Club"":""Verein 5"",""Nation"":""Nation 5"",""Class"":""Buben 2012"",""Group"":""U8 männlich""}]}";
            //string jsonResultExpected = @"{""type"":""racerunresult"",""data"":[{""Id"":""1"",""Position"":1,""StartNumber"":""1"",""Name"":""Nachname 1"",""Firstname"":""Vorname 1"",""Sex"":""W"",""Year"":2009,""Club"":""Verein 1"",""Nation"":""Nation 1"",""Class"":""Mädchen 2009"",""Group"":""U10 weiblich"",""Runtime"":""00:22,85"",""DisqualText"":null,""JustModified"":false},{""Id"":""4"",""Position"":2,""StartNumber"":""4"",""Name"":""Nachname 4"",""Firstname"":""Vorname 4"",""Sex"":""W"",""Year"":2014,""Club"":""Verein 4"",""Nation"":""Nation 4"",""Class"":""Mädchen 2014"",""Group"":""Bambini weiblich"",""Runtime"":""00:29,88"",""DisqualText"":null,""JustModified"":false},{""Id"":""2"",""Position"":3,""StartNumber"":""2"",""Name"":""Nachname 2"",""Firstname"":""Vorname 2"",""Sex"":""M"",""Year"":2013,""Club"":""Verein 2"",""Nation"":""Nation 2"",""Class"":""Buben 2013"",""Group"":""Bambini männlich"",""Runtime"":""00:39,11"",""DisqualText"":null,""JustModified"":false},{""Id"":""3"",""Position"":0,""StartNumber"":""3"",""Name"":""Nachname 3"",""Firstname"":""Vorname 3"",""Sex"":""M"",""Year"":2011,""Club"":""Verein 3"",""Nation"":""Nation 3"",""Class"":""Buben 2011"",""Group"":""U8 männlich"",""Runtime"":null,""DisqualText"":null,""JustModified"":false}]}";

            //Assert.AreEqual(jsonStartExpected, jsonStart);
            //Assert.AreEqual(jsonResultExpected, jsonResult);
        }
        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();
        }