-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from itn3000/fix-alias-skip
Fix CommandAttribute's name not working
- Loading branch information
Showing
2 changed files
with
76 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using FluentAssertions; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using System; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace MicroBatchFramework.Tests | ||
{ | ||
public class CommandAttributeTest | ||
{ | ||
class CommandAttributeTestCommand : BatchBase | ||
{ | ||
ResultContainer _Result; | ||
public CommandAttributeTestCommand(ResultContainer r) | ||
{ | ||
_Result = r; | ||
} | ||
[Command("test")] | ||
public void TestCommand(int value) | ||
{ | ||
_Result.X = value; | ||
} | ||
} | ||
class ResultContainer | ||
{ | ||
public int X; | ||
} | ||
[Fact] | ||
public async Task TestCommandName() | ||
{ | ||
var host = BatchHost.CreateDefaultBuilder() | ||
.ConfigureServices((c, services) => | ||
{ | ||
services.AddSingleton<ResultContainer>(); | ||
}) | ||
.UseBatchEngine<CommandAttributeTestCommand>(new string[]{ "test", "-value", "1" }) | ||
.Build(); | ||
var result = host.Services.GetService<ResultContainer>(); | ||
await host.RunAsync(); | ||
result.X.Should().Be(1); | ||
} | ||
|
||
} | ||
} |