Exemple #1
0
 public void EnsureSectionExists_AlreadyExists()
 {
     using (var tester = new IniFileTester(ValidSection1))
     {
         tester.TestFile.EnsureSectionExists("section");
         tester.AssertSection("section", "property", "value");
         tester.TestFile.Persist();
         tester.AssertFileContents(ValidSection1);
     }
 }
Exemple #2
0
 public void DeleteSection()
 {
     using (var tester = new IniFileTester(ValidSection1))
     {
         tester.TestFile.DeleteSection("section");
         Assert.IsFalse(tester.TestFile.SectionExists("section"));
         tester.TestFile.Persist();
         tester.AssertFileContents(String.Empty);
     }
 }
Exemple #3
0
 public void EnsureSectionExists_New()
 {
     using (var tester = new IniFileTester(ValidSection1))
     {
         tester.TestFile.EnsureSectionExists("section2");
         tester.AssertSection("section2");
         tester.TestFile.Persist();
         tester.AssertFileContents(ValidSection1 + "[section2]");
     }
 }
Exemple #4
0
 public void DeleteSection_Middle()
 {
     using (var tester = new IniFileTester(ValidSection1 + ValidSection2 + ValidSection3))
     {
         tester.TestFile.DeleteSection("section2");
         Assert.IsFalse(tester.TestFile.SectionExists("section2"));
         tester.TestFile.Persist();
         tester.AssertFileContents(ValidSection1 + ValidSection3);
     }
 }
Exemple #5
0
        public void DeleteProperty()
        {
            var properties = new SortedDictionary <string, string>();

            properties.Add("property", null);

            using (var tester = new IniFileTester(ValidSection1))
            {
                tester.TestFile.EditSection("section", properties);
                tester.AssertSection("section");
                tester.TestFile.Persist();
                tester.AssertFileContents("[section]" + Environment.NewLine);
            }
        }
Exemple #6
0
        public void EditProperty()
        {
            var properties = new List <KeyValuePair <string, string> >();

            properties.Add(new KeyValuePair <string, string>("property", "value2"));

            using (var tester = new IniFileTester(ValidSection1))
            {
                tester.TestFile.EditSection("section", properties);
                tester.AssertSection("section", "property", "value2");
                tester.TestFile.Persist();
                tester.AssertFileContents("[section]" + Environment.NewLine + "property=value2");
            }
        }
Exemple #7
0
        public void AddProperty()
        {
            var properties = new SortedDictionary <string, string>();

            properties.Add("property", "value");
            properties.Add("property2", "value2");

            using (var tester = new IniFileTester(ValidSection1))
            {
                tester.TestFile.EditSection("section", properties);
                tester.AssertSection("section", "property", "value", "property2", "value2");
                tester.TestFile.Persist();
                tester.AssertFileContents(ValidSection1 + "property2=value2");
            }
        }
Exemple #8
0
        public void AddAndEditProperties()
        {
            var properties = new SortedDictionary <string, string>();

            properties.Add("property", "value3");
            properties.Add("property2", "value2");

            using (var tester = new IniFileTester(ValidSection1))
            {
                tester.TestFile.EditSection("section", properties);
                tester.AssertSection("section", "property", "value3", "property2", "value2");
                tester.TestFile.Persist();
                tester.AssertFileContents("[section]" + Environment.NewLine +
                                          "property=value3" + Environment.NewLine +
                                          "property2=value2");
            }
        }
Exemple #9
0
 public void DeleteSection()
 {
     using (var tester = new IniFileTester(ValidSection1))
     {
         tester.TestFile.DeleteSection("section");
         Assert.IsFalse(tester.TestFile.SectionExists("section"));
         tester.TestFile.Persist();
         tester.AssertFileContents(String.Empty);
     }
 }
Exemple #10
0
        public void DeleteProperty()
        {
            var properties = new List<KeyValuePair<string, string>>();
            properties.Add(new KeyValuePair<string, string>("property", null));

            using (var tester = new IniFileTester(ValidSection1))
            {
                tester.TestFile.EditSection("section", properties);
                tester.AssertSection("section");
                tester.TestFile.Persist();
                tester.AssertFileContents("[section]" + Environment.NewLine);
            }
        }
Exemple #11
0
        public void AddAndEditProperties()
        {
            var properties = new List<KeyValuePair<string, string>>();
            properties.Add(new KeyValuePair<string, string>("property", "value3"));
            properties.Add(new KeyValuePair<string, string>("property2", "value2"));

            using (var tester = new IniFileTester(ValidSection1))
            {
                tester.TestFile.EditSection("section", properties);
                tester.AssertSection("section", "property", "value3", "property2", "value2");
                tester.TestFile.Persist();
                tester.AssertFileContents("[section]" + Environment.NewLine +
                    "property=value3" + Environment.NewLine +
                    "property2=value2");
            }
        }
Exemple #12
0
        public void AddProperty()
        {
            var properties = new List<KeyValuePair<string, string>>();
            properties.Add(new KeyValuePair<string, string>("property2", "value2"));

            using (var tester = new IniFileTester(ValidSection1))
            {
                tester.TestFile.EditSection("section", properties);
                tester.AssertSection("section", "property", "value", "property2", "value2");
                tester.TestFile.Persist();
                tester.AssertFileContents(ValidSection1 + "property2=value2");
            }
        }
Exemple #13
0
 public void EnsureSectionExists_New()
 {
     using (var tester = new IniFileTester(ValidSection1))
     {
         tester.TestFile.EnsureSectionExists("section2");
         tester.AssertSection("section2");
         tester.TestFile.Persist();
         tester.AssertFileContents(ValidSection1 + "[section2]");
     }
 }
Exemple #14
0
 public void EnsureSectionExists_AlreadyExists()
 {
     using (var tester = new IniFileTester(ValidSection1))
     {
         tester.TestFile.EnsureSectionExists("section");
         tester.AssertSection("section", "property", "value");
         tester.TestFile.Persist();
         tester.AssertFileContents(ValidSection1);
     }
 }
Exemple #15
0
 public void DeleteSection_Middle()
 {
     using (var tester = new IniFileTester(ValidSection1 + ValidSection2 + ValidSection3))
     {
         tester.TestFile.DeleteSection("section2");
         Assert.IsFalse(tester.TestFile.SectionExists("section2"));
         tester.TestFile.Persist();
         tester.AssertFileContents(ValidSection1 + ValidSection3);
     }
 }