public void CCFE_ConfigurationTest_PropertyList() { //ARRANGE List<CCFE_ConfigurationProperty> propertyList = new List<CCFE_ConfigurationProperty>(); propertyList.Add(new CCFE_ConfigurationProperty("TriggerMode", "5")); propertyList.Add(new CCFE_ConfigurationProperty("OverlapPercent", "75")); propertyList.Add(new CCFE_ConfigurationProperty("KnownHalAltitudeUnits", "feet")); propertyList.Add(new CCFE_ConfigurationProperty("KnownHalAltitude", "400")); propertyList.Add(new CCFE_ConfigurationProperty("Time", "3.8")); propertyList.Add(new CCFE_ConfigurationProperty("Distance", "10")); propertyList.Add(new CCFE_ConfigurationProperty("WaitForGpsFix", "yes")); propertyList.Add(new CCFE_ConfigurationProperty("Version", "1.0")); //ACT CCFE_Configuration config = new CCFE_Configuration(propertyList); //will cause assert to fail if shallow copy foreach (CCFE_ConfigurationProperty property in propertyList) { if (property.Name.Equals("TriggerMode")) { property.Value = "0"; break; } } //ASSERT Assert.IsNotNull(config); Assert.IsNotNull(config.PropertyList); Assert.IsTrue(config.getValue("TriggerMode").Equals("5")); Assert.IsTrue(config.getValue("OverlapPercent").Equals("75")); Assert.IsTrue(config.getValue("KnownHalAltitudeUnits").Equals("feet")); Assert.IsTrue(config.getValue("KnownHalAltitude").Equals("400")); Assert.IsTrue(config.getValue("Time").Equals("3.8")); Assert.IsTrue(config.getValue("Distance").Equals("10")); Assert.IsTrue(config.getValue("WaitForGpsFix").Equals("yes")); Assert.IsTrue(config.getValue("Version").Equals("1.0")); }
public void loadConfiguration(CCFE_Configuration config) { triggerModeComboBox.SelectedIndex = Convert.ToInt32(config.getValue(CCFE_Configuration.PROPERTY_TRIGGERMODE)); overlapTrackBar.Value = Convert.ToInt32(config.getValue(CCFE_Configuration.PROPERTY_OVERLAPPERCENT)); waitForGpsFixValue.Checked = (bool)config.getValue(CCFE_Configuration.PROPERTY_WAITFORGPSFIX).Equals("yes"); knownHalAltitudeValue.Text = config.getValue(CCFE_Configuration.PROPERTY_KNOWNHALALTITUDE); //sets the known hal altitude unit if (config.getValue(CCFE_Configuration.PROPERTY_KNOWNHALALTITUDEUNITS).Equals("feet")) { //feet knownHalAltitudeUnit.SelectedIndex = 0; } else { //meters knownHalAltitudeUnit.SelectedIndex = 1; } triggerPeriodValue.Text = config.getValue(CCFE_Configuration.PROPERTY_TIME); triggerDistanceValue.Text = config.getValue(CCFE_Configuration.PROPERTY_DISTANCE); //needed to move the trackbar label to its spot under the trackbar setTrackBarLabelLocationAndText(); }
public void CCFE_ConfigurationTest_SpecificVersion() { //ARRANGE //ACT CCFE_Configuration config = new CCFE_Configuration("1.0"); //ASSERT Assert.IsNotNull(config); Assert.IsNotNull(config.PropertyList); Assert.IsTrue(config.getValue("TriggerMode").Equals("5")); Assert.IsTrue(config.getValue("OverlapPercent").Equals("75")); Assert.IsTrue(config.getValue("KnownHalAltitudeUnits").Equals("feet")); Assert.IsTrue(config.getValue("KnownHalAltitude").Equals("400")); Assert.IsTrue(config.getValue("Time").Equals("3.8")); Assert.IsTrue(config.getValue("Distance").Equals("10")); Assert.IsTrue(config.getValue("WaitForGpsFix").Equals("yes")); Assert.IsTrue(config.getValue("Version").Equals("1.0")); }
public void getValueTest() { //ARRANGE CCFE_Configuration config = new CCFE_Configuration(); config.PropertyList.Add(new CCFE_ConfigurationProperty("TestProperty1", "TestValue1")); config.PropertyList.Add(new CCFE_ConfigurationProperty("TestProperty2", "TestValue2")); //ACT string result = config.getValue("TestProperty1"); //ASSERT Assert.IsTrue(result.Equals("TestValue1")); Assert.IsFalse(result.Equals("TestValue2")); }
public void save(CCFE_Configuration configuration) { string configurationFileText; configurationFileText = "[UserSettings]\n"; configurationFileText += "# CCFE v" + CCFE_Default.programVersion + " - " + DateTime.Now.ToString(CultureInfo.CurrentCulture) + "\n"; List<CCFE_ConfigurationProperty> configurationComments = CCFE_Default.getCommentPropertyPairs(configuration.getValue("Version")); foreach (CCFE_ConfigurationProperty property in configuration.PropertyList) { configurationFileText = configurationFileText + appendProperty(property, configurationComments); } System.IO.File.WriteAllText(FileLocation, configurationFileText); }