Exemple #1
0
 public void SectionExistsTrue()
 {
     using (var tester = new IniFileTester(ValidSection1))
     {
         Assert.IsTrue(tester.TestFile.SectionExists("section"));
     }
 }
Exemple #2
0
 public void SectionExistsFalse()
 {
     using (var tester = new IniFileTester(ValidSection1))
     {
         Assert.IsFalse(tester.TestFile.SectionExists("blah"));
     }
 }
Exemple #3
0
 public void SectionExistsFalse()
 {
     using (var tester = new IniFileTester(ValidSection1))
     {
         Assert.IsFalse(tester.TestFile.SectionExists("blah"));
     }
 }
Exemple #4
0
 public void SectionExistsTrue()
 {
     using (var tester = new IniFileTester(ValidSection1))
     {
         Assert.IsTrue(tester.TestFile.SectionExists("section"));
     }
 }
Exemple #5
0
 public void TryGetSection()
 {
     using (var tester = new IniFileTester(ValidSection1))
     {
         tester.AssertSection("section", "property", "value");
     }
 }
Exemple #6
0
 public void TryGetSection()
 {
     using (var tester = new IniFileTester(ValidSection1))
     {
         tester.AssertSection("section", "property", "value");
     }
 }
Exemple #7
0
 public void TryGetSectionDuplicatePropertyRegex()
 {
     using (var tester = new IniFileTester(DuplicatePropertySection))
     {
         Dictionary <string, string> properties;
         Assert.IsFalse(tester.TestFile.TryGetSection(new Regex("ectio"), out properties));
     }
 }
Exemple #8
0
 public void ReadInvalid()
 {
     AssertExtensions.ExpectException(() =>
     {
         using(var tester = new IniFileTester(InvalidIniFile))
         {
         }
     }, typeof(InvalidDataException), new Regex(String.Format(ErrorFormat, 1, Regex.Escape(InvalidIniFile))));
 }
Exemple #9
0
 public void ReadInvalid()
 {
     AssertExtensions.ExpectException(() =>
     {
         using (var tester = new IniFileTester(InvalidIniFile))
         {
         }
     }, typeof(InvalidDataException), new Regex(String.Format(ErrorFormat, 1, Regex.Escape(InvalidIniFile))));
 }
Exemple #10
0
 public void TryGetSectionCommentsAreNotProperties()
 {
     using (var tester = new IniFileTester(DuplicateCommentPropertySection))
     {
         Dictionary <string, string> properties;
         Assert.IsTrue(tester.TestFile.TryGetSection("section", out properties));
         Assert.AreEqual(0, properties.Count);
     }
 }
Exemple #11
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 #12
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 #13
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 #14
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 #15
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 #16
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 #17
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 #18
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 #19
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 #20
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 #21
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 #22
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 #23
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 #24
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 #25
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);
     }
 }