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)); }
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)); }
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 })); }
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 })); }