Ejemplo n.º 1
0
        public void TestSettingsImportExport()
        {
            //Import/export XML
            string testXMLfault = @"<?xmlversion=""1.0"" encoding=""utf-16""?><SettingData xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""><testpath>C:\Users\Alva\Desktop\Control Tests Device 2</testpath><frequency>0</frequency><clipsOn>false</clipsOn><mass>0</mass><load>0</load><shakertype>0</shakertype><paddtype>1</paddtype><n_devices>0</n_devices><n_channels>64</n_channels><duration>5</duration><timer_interval>1000</timer_interval><external_trigger>false</external_trigger><path>C:\Users\Alva\Desktop\default.xml</path><modified>false</modified></SettingData>";
            string testXML      = @"<?xml version=""1.0"" encoding=""utf-16""?><SettingData xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""><testpath>C:\Users\Alva\Desktop\Control Tests Device 2</testpath><frequency>0</frequency><clipsOn>false</clipsOn><mass>0</mass><load>0</load><shakertype>0</shakertype><paddtype>1</paddtype><n_devices>0</n_devices><n_channels>64</n_channels><duration>5</duration><timer_interval>1000</timer_interval><external_trigger>false</external_trigger><path>C:\Users\Alva\Desktop\default.xml</path><modified>false</modified></SettingData>";

            FilePersistentState <LoggerState> s = new FilePersistentState <LoggerState>();

            //How robust to exceptions
            bool res = s.ImportXML(testXMLfault);

            Assert.IsFalse(res);

            //On good xml
            res = s.ImportXML(testXML);
            Assert.IsTrue(res);
            Assert.IsTrue(s.data.n_channels == 64);

            string getXML;

            s.ExportXML(out getXML);

            Debug.WriteLine(testXML);
            Debug.WriteLine(getXML);

            Assert.IsTrue(testXML == getXML);
        }
Ejemplo n.º 2
0
        public void TestSettingsFiling()
        {
            string testXML = @"<?xml version=""1.0"" encoding=""utf-16""?><SettingData xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""><testpath>C:\Users\Alva\Desktop\Control Tests Device 2</testpath><frequency>0</frequency><clipsOn>false</clipsOn><mass>0</mass><load>0</load><shakertype>0</shakertype><paddtype>1</paddtype><n_devices>0</n_devices><n_channels>64</n_channels><duration>5</duration><timer_interval>1000</timer_interval><external_trigger>false</external_trigger><path>C:\Users\Alva\Desktop\default.xml</path><modified>false</modified></SettingData>";

            FilePersistentState <LoggerState> s = new FilePersistentState <LoggerState>();

            s.ImportXML(testXML);
            Assert.IsTrue(s.data.n_channels == 64);
            s.data.n_channels = 32;
            s.Save("test.xml");

            FilePersistentState <LoggerState> t = new FilePersistentState <LoggerState>();

            t.Load("test.xml");
            Assert.IsTrue(t.data.n_channels == 32);
        }