private void btnTemplateDelete_Click(object sender, RoutedEventArgs e)
 {
     if (cmbTemplate.SelectedValue is CBItem selected)
     {
         if (selected.Value is string configName)
         {
             _raceConfigurationPresets.DeleteConfiguration(configName);
             refreshConfigPresetsUI();
         }
     }
 }
Example #2
0
        public void RaceConfigurationPresets_Test()
        {
            RaceConfigurationPresets cfgPresets = new RaceConfigurationPresets(".");

            var configs = cfgPresets.GetConfigurations();

            Assert.AreEqual(2, configs.Count);
            Assert.IsTrue(configs.ContainsKey("DSV Erwachsene"));
            Assert.IsTrue(configs.ContainsKey("FIS Rennen Men"));

            // Create new Config
            var newConfig = new RaceConfiguration(configs["FIS Rennen Men"]);

            newConfig.Runs = 3;
            cfgPresets.SaveConfiguration("FIS Rennen - neu", newConfig);
            Assert.AreEqual(3, configs.Count);
            Assert.IsTrue(configs.ContainsKey("DSV Erwachsene"));
            Assert.IsTrue(configs.ContainsKey("FIS Rennen Men"));
            Assert.IsTrue(configs.ContainsKey("FIS Rennen - neu"));

            // Delete a config
            cfgPresets.DeleteConfiguration("FIS Rennen Men");
            Assert.AreEqual(2, configs.Count);
            Assert.IsTrue(configs.ContainsKey("DSV Erwachsene"));
            Assert.IsTrue(configs.ContainsKey("FIS Rennen - neu"));
            Assert.AreEqual(3, cfgPresets.GetConfigurations()["FIS Rennen - neu"].Runs);

            // Create new Config with unsafe name
            var newConfig2 = new RaceConfiguration(configs["DSV Erwachsene"]);

            newConfig.Runs = 3;
            cfgPresets.SaveConfiguration(@"abc\*:;? 123", newConfig);
            Assert.AreEqual(3, configs.Count);
            Assert.IsTrue(configs.ContainsKey("DSV Erwachsene"));
            Assert.IsTrue(configs.ContainsKey(@"abc; 123"));
            Assert.IsTrue(configs.ContainsKey("FIS Rennen - neu"));
        }