public void CreateCsvPluginSettingsTemplate() { CsvReaderPluginSettings ps = new CsvReaderPluginSettings() { SamiKey = "key here", MeasurementObject = "measurement object here if needed", MeasurementTag = "measurement tag here if needed", Password = "******", UserName = "******", ContentEncoding = "UTF-8", HasHeaders = true, CsvUri = "https://testi.com", DelimeterChar = ";", IsWebResource = true, MaxTimeToReadAtOnce = TimeSpan.FromHours(1.5), MeasurementTimeFieldHeader = "time", QuotationChar = '"', ReadConfigPath = "[path to read config]", AdditionalHttpHeaders = new List <string>(), ItemMap = new List <CsvItem>() }; ps.AdditionalHttpHeaders.Add("header 1"); ps.AdditionalHttpHeaders.Add("header 2"); ps.ItemMap.Add(new CsvItem() { Header = "item 1", SamiTag = "sami tag 1", Scale = new CsvReaderPlugin.ValueLinearScale() { Source = new CsvReaderPlugin.LinearScaleLimit() { From = 0, To = 10 }, Destination = new CsvReaderPlugin.LinearScaleLimit() { From = 0, To = 100 } } }); ps.ItemMap.Add(new CsvItem() { Header = "item 2", SamiTag = "sami tag 2" }); string xml = SerializeHelper.SerializeToStringWithDCS <CsvReaderPluginSettings>(ps); Trace.WriteLine(xml); Assert.IsNotNull(xml); CsvReaderPluginSettings dps = SerializeHelper.DeserializeWithDCS <CsvReaderPluginSettings>(xml); Assert.IsNotNull(dps); Assert.AreEqual(dps.SamiKey, ps.SamiKey); Assert.AreEqual(dps.ItemMap.Count, ps.ItemMap.Count); }
public void ReadAndDeserializeCsvPluginSettingsFile() { var xml = System.IO.File.ReadAllText(@"Path to settings file"); Trace.WriteLine(xml); Assert.IsNotNull(xml); CsvReaderPluginSettings dps = SerializeHelper.DeserializeWithDCS <CsvReaderPluginSettings>(xml); Assert.IsNotNull(dps); Assert.AreEqual(@"known csv uri", dps.CsvUri); Assert.AreEqual(dps.SamiKey, "key here"); Assert.AreEqual(dps.ItemMap.Count, 2); var firstItemMap = dps.ItemMap.First(); var lastItemMap = dps.ItemMap.Last(); Assert.IsNotNull(firstItemMap.Scale); Assert.IsNull(lastItemMap.Scale); Assert.AreEqual <double>(firstItemMap.Scale.ScaleValue(10), 100.0); }