コード例 #1
0
        public void SettingDataCollectionTest_ImportFromAttributes()
        {
            var mf = new MainForm();

            mf.Show();

            var c = new SettingDataMCollection(mf.MyDataFile);


            c.Add(new SettingDataM(typeof(Rectangle), "test", Rectangle.FromLTRB(8, 9, 100, 150))
            {
            }, new SettingDataM(typeof(int), "int_test", 9)
            {
            });

            var d = new XmlDocument();

            d.AppendChild(d.CreateElement("MyRoot"));
            d.DocumentElement.SetAttribute("test", "5|11|100|120");
            d.DocumentElement.SetAttribute("int_test", "10");

            c.ImportFromAttributes(d);

            Assert.AreEqual(Rectangle.FromLTRB(5, 11, 100, 120), c.GetValue("test"));
            Assert.AreEqual(10, c.GetValue("int_test"));
        }
コード例 #2
0
        public void SettingDataCollectionTest_GetValue()
        {
            var mf = new MainForm();

            mf.Show();

            var c = new SettingDataMCollection(mf.MyDataFile);

            c.Add(new SettingDataM(typeof(string), "test", "val1")
            {
            }, new SettingDataM(typeof(int), "testing", 16)
            {
            });

            Assert.AreEqual("val1", c.GetValue("test"));

            c.SetValue("test", "val2");

            Assert.AreEqual("val2", c.GetValue("test"));

            Assert.AreEqual(16, c.GetValue("testing"));

            Assert.IsNull(c.GetValue("abc"));
        }