public void NotOrderedWriteState() { StringWriter writer = new StringWriter(); IniWriter iniWriter = new IniWriter(writer); iniWriter.WriteKey("state", "Out of order"); }
/// <summary> /// Returns a proper IniWriter depending upon the type parameter. /// </summary> private IniWriter GetIniWriter(TextWriter reader, IniFileType type) { IniWriter result = new IniWriter(reader); switch (type) { case IniFileType.Standard: case IniFileType.WindowsStyle: // do nothing break; case IniFileType.PythonStyle: result.AssignDelimiter = ':'; result.CommentDelimiter = '#'; break; case IniFileType.SambaStyle: case IniFileType.MysqlStyle: result.AssignDelimiter = '='; result.CommentDelimiter = '#'; break; } return(result); }
public void KeyWithIndentation() { StringWriter writer = new StringWriter(); IniWriter iniWriter = new IniWriter(writer); iniWriter.Indentation = 2; iniWriter.WriteSection("Required"); iniWriter.WriteKey("independence day", "july"); Assert.AreEqual(" independence day = july", ReadLine(writer, 2)); iniWriter.Indentation = 0; }
public void SectionWithoutComment() { StringWriter writer = new StringWriter(); IniWriter iniWriter = new IniWriter(writer); Assert.AreEqual(IniWriteState.Start, iniWriter.WriteState); iniWriter.WriteSection("Test Section"); Assert.AreEqual("[Test Section]", ReadLine(writer, 1)); Assert.AreEqual(IniWriteState.Section, iniWriter.WriteState); }
public void EmptyWithoutComment() { StringWriter writer = new StringWriter(); IniWriter iniWriter = new IniWriter(writer); Assert.AreEqual(IniWriteState.Start, iniWriter.WriteState); iniWriter.WriteEmpty(); Assert.AreEqual("", ReadLine(writer, 1)); Assert.AreEqual(IniWriteState.BeforeFirstSection, iniWriter.WriteState); }
public void ReplaceEndOfLine() { StringWriter writer = new StringWriter(); IniWriter iniWriter = new IniWriter(writer); iniWriter.WriteSection("Required"); iniWriter.WriteKey("thanksgiving", "November\n 25th"); Assert.AreEqual("thanksgiving = November 25th", ReadLine(writer, 2)); }
public void KeyWithQuotesAndComment() { StringWriter writer = new StringWriter(); IniWriter iniWriter = new IniWriter(writer); iniWriter.UseValueQuotes = true; iniWriter.WriteSection("Required"); iniWriter.WriteKey("thanksgiving", "November 25th", "Football!"); iniWriter.UseValueQuotes = false; Assert.AreEqual("thanksgiving = \"November 25th\" ; Football!", ReadLine(writer, 2)); }
public void FlushAndClose() { StringWriter writer = new StringWriter(); IniWriter iniWriter = new IniWriter(writer); iniWriter.WriteSection("Required"); iniWriter.WriteKey("thanksgiving", "november 25th", "Football!"); iniWriter.Close(); Assert.AreEqual(IniWriteState.Closed, iniWriter.WriteState); }
public void KeyWithIndentation() { StringWriter writer = new StringWriter(); IniWriter iniWriter = new IniWriter(writer); iniWriter.Indentation = 2; iniWriter.WriteSection("Required"); iniWriter.WriteKey("independence day", "july"); Assert.AreEqual(" independence day = july", ReadLine(writer, 2)); iniWriter.Indentation = 0; }
public void SectionWithoutComment() { StringWriter writer = new StringWriter(); IniWriter iniWriter = new IniWriter(writer); Assert.AreEqual(IniWriteState.Start, iniWriter.WriteState); iniWriter.WriteSection("Test Section"); Assert.AreEqual("[Test Section]", ReadLine(writer, 1)); Assert.AreEqual(IniWriteState.Section, iniWriter.WriteState); }
public void EmptyWithoutComment() { StringWriter writer = new StringWriter(); IniWriter iniWriter = new IniWriter(writer); Assert.AreEqual(IniWriteState.Start, iniWriter.WriteState); iniWriter.WriteEmpty(); Assert.AreEqual("", ReadLine(writer, 1)); Assert.AreEqual(IniWriteState.BeforeFirstSection, iniWriter.WriteState); }
public void KeyWithQuotesAndComment() { StringWriter writer = new StringWriter(); IniWriter iniWriter = new IniWriter(writer); iniWriter.UseValueQuotes = true; iniWriter.WriteSection("Required"); iniWriter.WriteKey("thanksgiving", "November 25th", "Football!"); iniWriter.UseValueQuotes = false; Assert.AreEqual("thanksgiving = \"November 25th\" ; Football!", ReadLine(writer, 2)); }
/// <summary> /// Returns a proper IniWriter depending upon the type parameter. /// </summary> private IniWriter GetIniWriter(TextWriter reader, IniFileType type) { IniWriter result = new IniWriter(reader); switch(type) { case IniFileType.Standard: case IniFileType.WindowsStyle: // do nothing break; case IniFileType.PythonStyle: result.AssignDelimiter = ':'; result.CommentDelimiter = '#'; break; case IniFileType.SambaStyle: case IniFileType.MysqlStyle: result.AssignDelimiter = '='; result.CommentDelimiter = '#'; break; } return result; }
public void FlushAndClose() { StringWriter writer = new StringWriter(); IniWriter iniWriter = new IniWriter(writer); iniWriter.WriteSection("Required"); iniWriter.WriteKey("thanksgiving", "november 25th", "Football!"); iniWriter.Close(); Assert.AreEqual(IniWriteState.Closed, iniWriter.WriteState); }
public void ReplaceEndOfLine() { StringWriter writer = new StringWriter(); IniWriter iniWriter = new IniWriter(writer); iniWriter.WriteSection("Required"); iniWriter.WriteKey("thanksgiving", "November\n 25th"); Assert.AreEqual("thanksgiving = November 25th", ReadLine(writer, 2)); }
public void NotOrderedWriteState() { StringWriter writer = new StringWriter(); IniWriter iniWriter = new IniWriter(writer); iniWriter.WriteKey("state", "Out of order"); }