diff --git a/src/Pickles/Pickles.TestFrameworks.UnitTests/MsTest/WhenParsingMsTestResultsFileWithEmptyExampleValues.cs b/src/Pickles/Pickles.TestFrameworks.UnitTests/MsTest/WhenParsingMsTestResultsFileWithEmptyExampleValues.cs new file mode 100644 index 000000000..73e12777c --- /dev/null +++ b/src/Pickles/Pickles.TestFrameworks.UnitTests/MsTest/WhenParsingMsTestResultsFileWithEmptyExampleValues.cs @@ -0,0 +1,69 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright 2011 Jeffrey Cameron +// Copyright 2012-present PicklesDoc team and community contributors +// +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// -------------------------------------------------------------------------------------------------------------------- + + +using NUnit.Framework; +using PicklesDoc.Pickles.ObjectModel; +using PicklesDoc.Pickles.TestFrameworks.MsTest; +using System.Collections.Generic; + +namespace PicklesDoc.Pickles.TestFrameworks.UnitTests.MsTest +{ + [TestFixture] + public class WhenParsingMsTestResultsFileWithEmptyExampleValues : StandardTestSuite + { + public WhenParsingMsTestResultsFileWithEmptyExampleValues() + : base("MsTest." + "resuls-example-mstest-emptyexamplevalues.trx") + { + } + + [Test] + public new void ThenMatchWillBeFoundEvenIfACarriageReturnWasFoundInValueField() + { + var results = ParseResultsFile(); + + var feature = new Feature { Name = "Example With Empty Value" }; + var scenarioOutline = new ScenarioOutline { Name = "Testing test", Feature = feature }; + scenarioOutline.Steps = new List(); + + var examples = new Table(); + examples.HeaderRow = new TableRow(); + examples.HeaderRow.Cells.Add("result1"); + examples.HeaderRow.Cells.Add("result2"); + examples.HeaderRow.Cells.Add("result3"); + var row = new TableRow(); + row.Cells.Add("1"); + row.Cells.Add("2"); + row.Cells.Add("3"); + examples.DataRows = new List(); + examples.DataRows.Add(row); + row = new TableRow(); + row.Cells.Add("1"); + row.Cells.Add(""); + row.Cells.Add("4"); + examples.DataRows.Add(row); + + scenarioOutline.Examples = new List(); + scenarioOutline.Examples.Add(new Example() { TableArgument = examples }); + + var actualResult = results.GetExampleResult(scenarioOutline, new string[] { "1", "", "4" }); + } + } +} diff --git a/src/Pickles/Pickles.TestFrameworks.UnitTests/MsTest/resuls-example-mstest-emptyexamplevalues.trx b/src/Pickles/Pickles.TestFrameworks.UnitTests/MsTest/resuls-example-mstest-emptyexamplevalues.trx new file mode 100644 index 000000000..9ff3c5600 --- /dev/null +++ b/src/Pickles/Pickles.TestFrameworks.UnitTests/MsTest/resuls-example-mstest-emptyexamplevalues.trx @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + Testing test: Variant 1 + + + + FeatureTitle + Example With Empty Value + + + VariantName + Variant 1 + + + Parameter:result3 + 4 + + + Parameter:result1 + 1 + + + Parameter:result2 + + + + + + + + Testing test: Variant 0 + + + + FeatureTitle + Example With Empty Value + + + VariantName + Variant 0 + + + Parameter:result3 + 3 + + + Parameter:result1 + 1 + + + Parameter:result2 + 2 + + + + + + + + + + + + + + + + + When I do something +-> done: StepDefinition1.WhenIDoSomething() (0.0s) +Then the 1 should equal 2 and return 3 +-> done: StepDefinition1.ThenTheShouldEqualAndReturn("1", "2", "3") (0.0s) + + + + + When I do something +-> done: StepDefinition1.WhenIDoSomething() (0.0s) +Then the 1 should equal and return 4 +-> done: StepDefinition1.ThenTheShouldEqualAndReturn("1", "", "4") (0.0s) + + + + \ No newline at end of file diff --git a/src/Pickles/Pickles.TestFrameworks.UnitTests/Pickles.TestFrameworks.UnitTests.csproj b/src/Pickles/Pickles.TestFrameworks.UnitTests/Pickles.TestFrameworks.UnitTests.csproj index 2ee7a2187..38cb30692 100644 --- a/src/Pickles/Pickles.TestFrameworks.UnitTests/Pickles.TestFrameworks.UnitTests.csproj +++ b/src/Pickles/Pickles.TestFrameworks.UnitTests/Pickles.TestFrameworks.UnitTests.csproj @@ -62,6 +62,7 @@ + @@ -159,6 +160,7 @@ Designer + diff --git a/src/Pickles/Pickles.TestFrameworks/MsTest/MsTestElementExtensions.cs b/src/Pickles/Pickles.TestFrameworks/MsTest/MsTestElementExtensions.cs index bb0ccdb6a..a401a19f7 100644 --- a/src/Pickles/Pickles.TestFrameworks/MsTest/MsTestElementExtensions.cs +++ b/src/Pickles/Pickles.TestFrameworks/MsTest/MsTestElementExtensions.cs @@ -152,7 +152,7 @@ internal static List DetermineValuesInScenario(this XElement element) { if ((property.Descendants(Ns + "Key").FirstOrDefault()?.Value ?? string.Empty).StartsWith("Parameter:")) { - valuesInScenario.Add(property.Descendants(Ns + "Value").FirstOrDefault()?.Value ?? string.Empty); + valuesInScenario.Add(property.Descendants(Ns + "Value").FirstOrDefault()?.Value.Trim() ?? string.Empty); } }