Add costructors to LineParser.

This commit is contained in:
Daniel Kraus 2015-06-21 06:12:30 +02:00
parent 85800ebd75
commit cfbf3c7859
2 changed files with 20 additions and 2 deletions

View File

@ -55,8 +55,7 @@ namespace Tests
[Test] [Test]
public void ParseLineWithQuotesAndPunctuation() public void ParseLineWithQuotesAndPunctuation()
{ {
LineParser lp = new LineParser(); LineParser lp = new LineParser("this-is \"a , simple ;\" line");
lp.Line = "this-is \"a , simple ;\" line";
Assert.AreEqual("this-is", lp.Fields[0]); Assert.AreEqual("this-is", lp.Fields[0]);
Assert.AreEqual("a , simple ;", lp.Fields[1]); Assert.AreEqual("a , simple ;", lp.Fields[1]);
Assert.AreEqual("line", lp.Fields[2]); Assert.AreEqual("line", lp.Fields[2]);

View File

@ -56,6 +56,25 @@ namespace zaaReloaded2.Dictionaries
#endregion #endregion
#region Constructors
/// <summary>
/// Constructs a LineParser object without a line.
/// </summary>
public LineParser() { }
/// <summary>
/// Constructs a LineParser object with an initial <paramref name="line"/>.
/// </summary>
/// <param name="line">Initial line to parse.</param>
public LineParser(string line)
: this()
{
Line = line;
}
#endregion
#region Private methods #region Private methods
void ParseLine() void ParseLine()