Exemple #1
0
            public void When_Unmodified_DoesRetainEverything(string original)
            {
                var config = new ConfigIni();

                config.Read(new StringReader(original));
                var writer = new StringWriter();

                config.Write(writer);

                Assert.That(writer.ToString(), Is.EqualTo(original));
            }
Exemple #2
0
            public void When_UnmodifiedFile_IsUnchanged(string file)
            {
                var filePath = TestUtils.GetTestDataPath(file);
                var reader   = File.OpenText(filePath);
                var config   = new ConfigIni();

                config.Read(reader);
                reader.Close();

                var fileContent = File.ReadAllText(filePath);
                var writer      = new StringWriter();

                config.Write(writer);
                var writerContent = writer.ToString();

                Assert.That(writerContent, Is.EqualTo(fileContent));
            }
Exemple #3
0
            public void When_HasSections_RelaysCallsToSections()
            {
                var callLog     = new List <ConfigIniSection>();
                var config      = new ConfigIni();
                var spySectionA = new SpyConfigIniSection("A")
                {
                    Write_CallLog = callLog
                };
                var spySectionB = new SpyConfigIniSection("B")
                {
                    Write_CallLog = callLog
                };

                config.Sections.Add(spySectionA);
                config.Sections.Add(spySectionB);

                var writer = new StringWriter();

                config.Write(writer);
                Assert.That(callLog, Is.EquivalentTo(new[] { spySectionA, spySectionB }));
            }
Exemple #4
0
            public void When_HasNullSections_DoesSkipNull()
            {
                var callLog     = new List <ConfigIniSection>();
                var config      = new ConfigIni();
                var spySectionA = new SpyConfigIniSection("A")
                {
                    Write_CallLog = callLog
                };
                var spySectionB = new SpyConfigIniSection("B")
                {
                    Write_CallLog = callLog
                };

                config.Sections.Add(spySectionA);
                config.Sections.Add(null);
                config.Sections.Add(spySectionB);

                var writer = new StringWriter();

                config.Write(writer);
                Assert.That(config.Sections, Has.Count.EqualTo(3));
                Assert.That(callLog, Is.EquivalentTo(new[] { spySectionA, spySectionB }));
            }