Skip to content

Commit 37ae756

Browse files
authored
Merge pull request #68 from dotnet-campus/t/walterlv/interceptor
测试弃元
2 parents fbf19e8 + a3819b0 commit 37ae756

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/DotNetCampus.CommandLine.Tests/CommandMatching/AddHandlerTests.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ public async Task AddHandler_TypedDelegate(string[] args, string expectedCommand
224224
await Task.Yield();
225225
matched = o.Value;
226226
})
227+
.AddHandler<DefaultOptions>(_ => { })
227228
.RunAsync();
228229
var matchedTypeName = result.HandledBy!.GetType().Name;
229230

@@ -232,6 +233,26 @@ public async Task AddHandler_TypedDelegate(string[] args, string expectedCommand
232233
Assert.AreEqual(expectedValue, matched);
233234
}
234235

236+
[TestMethod]
237+
[DataRow(TestCommandLineStyle.Flexible, DisplayName = "[Flexible] foo")]
238+
[DataRow(TestCommandLineStyle.DotNet, DisplayName = "[DotNet] foo")]
239+
[DataRow(TestCommandLineStyle.Gnu, DisplayName = "[Gnu] foo")]
240+
[DataRow(TestCommandLineStyle.Windows, DisplayName = "[Windows] foo")]
241+
public void AddHandler_Discard /* 弃元 */(TestCommandLineStyle style)
242+
{
243+
// Arrange
244+
var commandLine = CommandLine.Parse([], style.ToParsingOptions());
245+
246+
// Act
247+
var result = commandLine
248+
.AddHandler<DefaultOptions>(_ => { })
249+
.Run();
250+
var matchedTypeName = result.HandledBy!.GetType().Name;
251+
252+
// Assert
253+
Assert.AreEqual(nameof(DefaultOptions), matchedTypeName);
254+
}
255+
235256
// ReSharper disable once RedundantAssignment
236257
private int RunWithExitCode<T>(ref T field, T value)
237258
{

0 commit comments

Comments
 (0)