public void When_LineIsInvalid_TreatsAsText(string line) { var configIni = new ConfigIni(); var currentSection = new ConfigIniSection(); configIni.Sections.Add(currentSection); Assert.That(() => configIni.ReadLineWithoutLineEnding(line, ref currentSection), Throws.Nothing); var tokenT = AssertSingleAddedTokenToSection <TextToken>(configIni, currentSection); Assert.That(tokenT.Text, Is.EqualTo(line)); }
public void When_LineIsNull_DoesNothing(string line) { var configIni = new ConfigIni(); var currentSection = new ConfigIniSection(); configIni.Sections.Add(currentSection); Assert.That(() => configIni.ReadLineWithoutLineEnding(line, ref currentSection), Throws.Nothing); Assert.That(configIni.Sections, Has.Count.EqualTo(1)); Assert.That(configIni.Sections[0], Is.SameAs(currentSection)); Assert.That(configIni.Sections[0].Tokens, Is.Empty); }
public void When_LineIsComment(string line) { var configIni = new ConfigIni(); var currentSection = new ConfigIniSection(); configIni.Sections.Add(currentSection); Assert.That(() => configIni.ReadLineWithoutLineEnding(line, ref currentSection), Throws.Nothing); var tokenT = AssertSingleAddedTokenToSection <CommentToken>(configIni, currentSection); Assert.That(tokenT.Lines, Has.Count.EqualTo(1)); Assert.That(tokenT.Lines[0].ToString(), Is.EqualTo(line)); }
public void When_LineIsRemoveAll(string line, string expectedKey) { var configIni = new ConfigIni(); var currentSection = new ConfigIniSection(); configIni.Sections.Add(currentSection); Assert.That(() => configIni.ReadLineWithoutLineEnding(line, ref currentSection), Throws.Nothing); var tokenT = AssertSingleAddedTokenToSection <InstructionToken>(configIni, currentSection); Assert.That(tokenT.InstructionType, Is.EqualTo(InstructionType.RemoveAll)); Assert.That(tokenT.Key, Is.EqualTo(expectedKey)); Assert.That(tokenT.Value, Is.Null); }
public void When_LineIsRepeatedComment(string[] lines) { var configIni = new ConfigIni(); var currentSection = new ConfigIniSection(); configIni.Sections.Add(currentSection); foreach (var line in lines) { Assert.That(() => configIni.ReadLineWithoutLineEnding(line, ref currentSection), Throws.Nothing); } var tokenT = AssertSingleAddedTokenToSection <CommentToken>(configIni, currentSection); Assert.That(tokenT.Lines, Has.Count.EqualTo(lines.Length)); Assert.That(tokenT.GetStringLines(), Is.EquivalentTo(lines)); }
public void When_LineIsSectionHeader(string line, string expectedName, string expectedWastePrefix = null, string expectedWasteSuffix = null) { var configIni = new ConfigIni(); var initialSection = new ConfigIniSection(); configIni.Sections.Add(initialSection); var currentSection = initialSection; Assert.That(() => configIni.ReadLineWithoutLineEnding(line, ref currentSection), Throws.Nothing); Assert.That(initialSection, Is.Not.SameAs(currentSection)); Assert.That(currentSection, Is.Not.Null); Assert.That(configIni.Sections, Has.Count.EqualTo(2)); Assert.That(configIni.Sections[0], Is.SameAs(initialSection)); Assert.That(configIni.Sections[1], Is.SameAs(currentSection)); Assert.That(currentSection.Name, Is.EqualTo(expectedName)); Assert.That(currentSection.LineWastePrefix, Is.EqualTo(expectedWastePrefix)); Assert.That(currentSection.LineWasteSuffix, Is.EqualTo(expectedWasteSuffix)); }