public void TestParseXmlSeries(String fileName) { WaterOneFlow10Parser parser = new WaterOneFlow10Parser(); string basePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestFiles"); string xmlFileName = Path.Combine(basePath, fileName); IList <Series> seriesList = parser.ParseGetValues(xmlFileName); }
public void TestParseDataSeries(String samplesPath) { IWaterOneFlowParser parser = new WaterOneFlow10Parser(); string xmlDirectory = GetXmlTempDirectory(); // we want a clean set of test cases CleanAndCopySamplesFiles(xmlDirectory, samplesPath); string[] fileNames = Directory.GetFiles(xmlDirectory); foreach (string fileName in fileNames) { IList <Series> seriesList = parser.ParseGetValues(fileName); Assert.Greater(seriesList.Count, 0); Assert.Greater(seriesList[0].ValueCount, 0, "Error in filename '" + fileName + "' the number of values in the seriesList must be greater than zero."); } }
public void TestSaveMultipleSeries() { string tempDir = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "hydrodesktop"); string[] files = System.IO.Directory.GetFiles(tempDir); Array.Sort(files); IWaterOneFlowParser parser = new WaterOneFlow10Parser(); Theme theme1 = new Theme("SaveValuesTest1", "Test on Save Values"); ActualDataManager manager = HydroDesktop.Database.Config.ActualDataManager(); foreach (string fileName in files) { IList <Series> seriesList = parser.ParseGetValues(fileName); Series series1 = seriesList[0]; manager.SaveSeries(series1, theme1, OverwriteOptions.Copy); } }
/// <summary> /// Converts the xml file to a list of data series objects. /// In most cases the list will only contain one object. /// </summary> /// <param name="xmlFile">The name of the xml file</param> /// <returns>the data series list or null in case of error</returns> public IList <Series> DataSeriesFromXml(string xmlFile) { IList <Series> seriesList = null; try { WaterOneFlow10Parser parser = new WaterOneFlow10Parser(); seriesList = parser.ParseGetValues(xmlFile); if (seriesList == null) { MessageBox.Show("There was an error parsing the WaterML document. " + "Please check if the document is in correct WaterML 1.0 format."); return(null); } } catch { //in case of error - return an empty list } return(seriesList); }