Skip to content

Commit 23cba7b

Browse files
committed
change over to use the engine result
1 parent 2ada6f7 commit 23cba7b

File tree

7 files changed

+14
-22
lines changed

7 files changed

+14
-22
lines changed

FluentCommandLineParser.Tests/FluentCommandLineParser/when_executing_parse_operation/with_a_parser_engine_that_is_custom.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class with_a_parser_engine_that_is_custom : FluentCommandLineParserTestCo
4848

4949
mockedEngine
5050
.Setup(x => x.Parse(args))
51-
.Returns(new List<ParsedOption>())
51+
.Returns(Create<ParserEngineResult>())
5252
.Verifiable();
5353
};
5454

FluentCommandLineParser.Tests/FluentCommandLineParser/when_executing_parse_operation/with_options_that_are_specified_in_the_args.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,16 @@ class with_options_that_are_specified_in_the_args : FluentCommandLineParserTestC
7676
_blankOption.Setup(x => x.Bind(_parsedBlankOption)).Verifiable();
7777
sut.Options.Add(_blankOption.Object);
7878

79-
var parserEngineResult = new List<ParsedOption>
79+
var parsedOptions = new List<ParsedOption>
8080
{
8181
_parsedOptionThatHasCallback,
8282
_parsedOptionThatIsRequired,
8383
_parsedBlankOption
8484
};
8585

86-
args = CreateArgsFromKvp(parserEngineResult);
86+
var parserEngineResult = new ParserEngineResult(parsedOptions, CreateEmptyList<string>());
87+
88+
args = CreateArgsFromKvp(parsedOptions);
8789

8890
var parserEngineMock = new Mock<ICommandLineParserEngine>();
8991
parserEngineMock.Setup(x => x.Parse(args)).Returns(parserEngineResult);

FluentCommandLineParser.Tests/FluentCommandLineParser/when_executing_parse_operation/with_options_that_have_not_been_setup.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ class with_options_that_have_not_been_setup : FluentCommandLineParserTestContext
5252
args = CreateArgsFromKvp(additionalOptions);
5353

5454
var mockEngine = new Mock<ICommandLineParserEngine>();
55-
mockEngine.Setup(x => x.Parse(args)).Returns(additionalOptions);
55+
56+
var result = new ParserEngineResult(additionalOptions, CreateEmptyList<string>());
57+
58+
mockEngine.Setup(x => x.Parse(args)).Returns(result);
5659
sut.ParserEngine = mockEngine.Object;
5760
};
5861

FluentCommandLineParser.Tests/TestContext/TestContext.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@
2727
using System.Globalization;
2828
using System.Linq;
2929
using Fclp.Internals.Parsing;
30+
using Fclp.Tests.Internals;
3031
using Machine.Specifications;
3132

3233
namespace Fclp.Tests
3334
{
34-
public abstract class TestContext<T>
35+
public abstract class TestContext<T> : TestContextBase<T> where T : class
3536
{
36-
protected static T sut;
37-
protected static Exception error;
38-
3937
protected static void CatchAnyError(Action test)
4038
{
4139
error = Catch.Exception(test);

FluentCommandLineParser/FluentCommandLineParser.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ public ICommandLineOptionFluent<T> Setup<T>(string longOption)
221221
/// <returns>An <see cref="ICommandLineParserResult"/> representing the results of the parse operation.</returns>
222222
public ICommandLineParserResult Parse(string[] args)
223223
{
224-
var parsedOptions = this.ParserEngine.Parse(args).ToList();
224+
var parserEngineResult = this.ParserEngine.Parse(args);
225+
var parsedOptions = parserEngineResult.ParsedOptions.ToList();
225226

226227
var result = new CommandLineParserResult { EmptyArgs = parsedOptions.IsNullOrEmpty() };
227228

FluentCommandLineParser/Internals/Parsing/CommandLineParserEngineMark2.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,5 @@ static bool IsEndOfOptionsKey(string arg)
146146
{
147147
return string.Equals(arg, SpecialCharacters.EndOfOptionsKey, StringComparison.InvariantCultureIgnoreCase);
148148
}
149-
150-
/// <summary>
151-
/// Parses the specified <see><cref>T:System.String[]</cref></see> into key value pairs.
152-
/// </summary>
153-
/// <param name="args">The <see><cref>T:System.String[]</cref></see> to parse.</param>
154-
/// <returns>An <see cref="IEnumerable{T}"/> containing the results of the parse operation.</returns>
155-
IEnumerable<ParsedOption> ICommandLineParserEngine.Parse(string[] args)
156-
{
157-
return Parse(args).ParsedOptions;
158-
}
159149
}
160150
}

FluentCommandLineParser/Internals/Parsing/ICommandLineParserEngine.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
// POSSIBILITY OF SUCH DAMAGE.
2323
#endregion
2424

25-
using System.Collections.Generic;
26-
2725
namespace Fclp.Internals.Parsing
2826
{
2927
/// <summary>
@@ -36,6 +34,6 @@ public interface ICommandLineParserEngine
3634
/// </summary>
3735
/// <param name="args">The <see><cref>T:System.String[]</cref></see> to parse.</param>
3836
/// <returns>An <see cref="ICommandLineParserResult"/> representing the results of the parse operation.</returns>
39-
IEnumerable<ParsedOption> Parse(string[] args);
37+
ParserEngineResult Parse(string[] args);
4038
}
4139
}

0 commit comments

Comments
 (0)