예제 #1
0
        public void TestWriteXml()
        {
            string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase.Substring(8)), "setting.xml");
            string xml  = @"<?xml version=""1.0"" encoding=""UTF-8""?>
<setting />
";

            File.WriteAllText(path, xml, Encoding.UTF8);
            SettingModel setting = new SettingModel(path);

            setting.CodeStyles.Add(new CodeStyleModel()
            {
                Label   = "None",
                Comment = ""
            });
            setting.DefaultValues.Add(new DefaultValueModel()
            {
                Id    = "cmbFont1",
                Value = "Microsoft YaHei Mono"
            });
            setting.Tables.Add(new TableModel()
            {
                Label      = "Blue Title Table",
                Size       = "large",
                Row        = 2,
                Column     = 2,
                ForeColor  = "ffffff",
                BackColor  = "2e75b5",
                HeadInLeft = true
            });
            setting.VSCode = @"E:\ToolsDevelop\Microsoft VS Code\Code.exe";

            setting.WriteXml();

            SettingModel saved = new SettingModel(path);

            Assert.AreEqual(setting.CodeStyles.Count, saved.CodeStyles.Count);
            Assert.AreEqual(setting.CodeStyles[0].Label, saved.CodeStyles[0].Label);
            Assert.AreEqual(setting.CodeStyles[0].Comment, saved.CodeStyles[0].Comment);

            Assert.AreEqual(setting.DefaultValues.Count, saved.DefaultValues.Count);
            Assert.AreEqual(setting.DefaultValues[0].Id, saved.DefaultValues[0].Id);
            Assert.AreEqual(setting.DefaultValues[0].Value, saved.DefaultValues[0].Value);

            Assert.AreEqual(setting.Tables.Count, saved.Tables.Count);
            Assert.AreEqual(setting.Tables[0].Label, saved.Tables[0].Label);
            Assert.AreEqual(setting.Tables[0].Size, saved.Tables[0].Size);
            Assert.AreEqual(setting.Tables[0].Row, saved.Tables[0].Row);
            Assert.AreEqual(setting.Tables[0].Column, saved.Tables[0].Column);
            Assert.AreEqual(setting.Tables[0].ForeColor, saved.Tables[0].ForeColor);
            Assert.AreEqual(setting.Tables[0].BackColor, saved.Tables[0].BackColor);
            Assert.AreEqual(setting.Tables[0].HeadInLeft, saved.Tables[0].HeadInLeft);

            Assert.AreEqual(setting.VSCode, saved.VSCode);
        }
예제 #2
0
 private void SaveSetting()
 {
     setting?.WriteXml();
 }