From 9e0f8a85ae4a10e816099d78717f17af42cc917e Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Sun, 21 Jun 2015 06:15:27 +0200 Subject: [PATCH] Add HasFields property to LineParser. --- Tests/LineParserTest.cs | 9 +++++++++ zaaReloaded2/Dictionaries/LineParser.cs | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/Tests/LineParserTest.cs b/Tests/LineParserTest.cs index b596de5..db2fd24 100755 --- a/Tests/LineParserTest.cs +++ b/Tests/LineParserTest.cs @@ -60,5 +60,14 @@ namespace Tests Assert.AreEqual("a , simple ;", lp.Fields[1]); Assert.AreEqual("line", lp.Fields[2]); } + + [Test] + public void ParseLineWithoutFields() + { + LineParser lp = new LineParser("# no fields"); + Assert.IsFalse(lp.HasFields); + lp.Line = "two fields"; + Assert.IsTrue(lp.HasFields); + } } } diff --git a/zaaReloaded2/Dictionaries/LineParser.cs b/zaaReloaded2/Dictionaries/LineParser.cs index 1815e7d..ec9f81e 100755 --- a/zaaReloaded2/Dictionaries/LineParser.cs +++ b/zaaReloaded2/Dictionaries/LineParser.cs @@ -54,6 +54,18 @@ namespace zaaReloaded2.Dictionaries /// public string[] Fields { get; private set; } + /// + /// Indicates whether the parsed + /// contains fields. + /// + public bool HasFields + { + get + { + return Fields.Length > 0; + } + } + #endregion #region Constructors