Ejemplo n.º 1
0
 public void SectionExistsTrue()
 {
     using (var tester = new IniFileTester(ValidSection1))
     {
         Assert.IsTrue(tester.TestFile.SectionExists("section"));
     }
 }
Ejemplo n.º 2
0
 public void SectionExistsFalse()
 {
     using (var tester = new IniFileTester(ValidSection1))
     {
         Assert.IsFalse(tester.TestFile.SectionExists("blah"));
     }
 }
Ejemplo n.º 3
0
 public void SectionExistsFalse()
 {
     using (var tester = new IniFileTester(ValidSection1))
     {
         Assert.IsFalse(tester.TestFile.SectionExists("blah"));
     }
 }
Ejemplo n.º 4
0
 public void SectionExistsTrue()
 {
     using (var tester = new IniFileTester(ValidSection1))
     {
         Assert.IsTrue(tester.TestFile.SectionExists("section"));
     }
 }
Ejemplo n.º 5
0
 public void TryGetSection()
 {
     using (var tester = new IniFileTester(ValidSection1))
     {
         tester.AssertSection("section", "property", "value");
     }
 }
Ejemplo n.º 6
0
 public void TryGetSection()
 {
     using (var tester = new IniFileTester(ValidSection1))
     {
         tester.AssertSection("section", "property", "value");
     }
 }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 8
0
 public void ReadInvalid()
 {
     AssertExtensions.ExpectException(() =>
     {
         using(var tester = new IniFileTester(InvalidIniFile))
         {
         }
     }, typeof(InvalidDataException), new Regex(String.Format(ErrorFormat, 1, Regex.Escape(InvalidIniFile))));
 }
Ejemplo n.º 9
0
 public void ReadInvalid()
 {
     AssertExtensions.ExpectException(() =>
     {
         using (var tester = new IniFileTester(InvalidIniFile))
         {
         }
     }, typeof(InvalidDataException), new Regex(String.Format(ErrorFormat, 1, Regex.Escape(InvalidIniFile))));
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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]");
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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]");
     }
 }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
     }
 }