-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bilal Fazlani
committed
Jan 3, 2018
1 parent
e435ebb
commit e9add62
Showing
4 changed files
with
50 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using CommandDotNet.Attributes; | ||
using FluentAssertions; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace CommandDotNet.Tests | ||
{ | ||
public class InheritedTests : TestBase | ||
{ | ||
public InheritedTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public void CanInheriOptions() | ||
{ | ||
AppRunner<InheritedApp> appRunner = new AppRunner<InheritedApp>(); | ||
appRunner.Run("--value", "10", "GetValue").Should().Be(10, "10 is passed as root option"); | ||
appRunner.Run("GetValue", "--value", "10").Should().Be(10, "10 is passed as command option"); | ||
appRunner.Run("GetValue").Should().Be(0, "no option is passed"); | ||
} | ||
} | ||
|
||
public class InheritedApp | ||
{ | ||
private readonly int _value; | ||
|
||
public InheritedApp([Option(Inherited = true)]int value) | ||
{ | ||
_value = value; | ||
} | ||
|
||
public int GetValue() | ||
{ | ||
return _value; | ||
} | ||
} | ||
} |
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
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