コード例 #1
0
        public void CreateRemoteMXPluginSettingsTemplate()
        {
            RemoteMXPluginSettings ps = new RemoteMXPluginSettings()
            {
                SamiKey              = "key here",
                ChannelMap           = new Dictionary <string, string>(),
                MeasurementObject    = "measurement object here if needed",
                MeasurementTag       = "measurement tag here if needed",
                Password             = "******",
                UserName             = "******",
                SiteId               = 0,
                ReadConfigPath       = "path to read config file, which contains newest read measurement time",
                SaveMappedValuesOnly = true,
                MaxTimeToReadAtOnce  = TimeSpan.FromHours(26.5)
            };

            ps.ChannelMap.Add("rmx-channel-1", "sami-tag1");
            ps.ChannelMap.Add("rmx-channel-2", "sami-tag2");


            string xml = SerializeHelper.SerializeToStringWithDCS <RemoteMXPluginSettings>(ps);

            Trace.WriteLine(xml);

            Assert.IsNotNull(xml);

            RemoteMXPluginSettings dps = SerializeHelper.DeserializeWithDCS <RemoteMXPluginSettings>(xml);

            Assert.IsNotNull(dps);
            Assert.AreEqual(dps.SamiKey, ps.SamiKey);
            Assert.AreEqual(dps.ChannelMap.Count, ps.ChannelMap.Count);
        }
コード例 #2
0
        public void ReadAndDeserializeRemoteMXPluginSettingsFile()
        {
            var xml = System.IO.File.ReadAllText(@"Path to settings file");

            Trace.WriteLine(xml);

            Assert.IsNotNull(xml);

            RemoteMXPluginSettings dps = SerializeHelper.DeserializeWithDCS <RemoteMXPluginSettings>(xml);

            Assert.IsNotNull(dps);
            Assert.AreEqual(dps.SamiKey, "key here");
            Assert.AreEqual(dps.ChannelMap.Count, 2);
            Assert.AreEqual <TimeSpan>(TimeSpan.FromDays(1), dps.MaxTimeToReadAtOnce);
        }