-
Notifications
You must be signed in to change notification settings - Fork 385
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 #2351 from KathleenDollard/powderhouse-subsystem-f…
…ixes-and-directives Powderhouse directives
- Loading branch information
Showing
34 changed files
with
1,167 additions
and
458 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
45 changes: 45 additions & 0 deletions
45
src/System.CommandLine.Subsystems.Tests/DiagramSubsystemTests.cs
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,45 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using FluentAssertions; | ||
using System.CommandLine.Directives; | ||
using System.CommandLine.Parsing; | ||
using Xunit; | ||
|
||
namespace System.CommandLine.Subsystems.Tests; | ||
|
||
public class DiagramSubsystemTests | ||
{ | ||
|
||
[Theory] | ||
[ClassData(typeof(TestData.Diagram))] | ||
public void Diagram_is_activated_only_when_requested(string input, bool expectedIsActive) | ||
{ | ||
CliRootCommand rootCommand = [new CliCommand("x")]; | ||
var configuration = new CliConfiguration(rootCommand); | ||
var subsystem = new DiagramSubsystem(); | ||
var args = CliParser.SplitCommandLine(input).ToList().AsReadOnly(); | ||
|
||
Subsystem.Initialize(subsystem, configuration, args); | ||
var parseResult = CliParser.Parse(rootCommand, input, configuration); | ||
var isActive = Subsystem.GetIsActivated(subsystem, parseResult); | ||
|
||
isActive.Should().Be(expectedIsActive); | ||
} | ||
|
||
[Theory] | ||
[ClassData(typeof(TestData.Diagram))] | ||
public void String_directive_supplies_string_or_default_and_is_activated_only_when_requested(string input, bool expectedIsActive) | ||
{ | ||
CliRootCommand rootCommand = [new CliCommand("x")]; | ||
var configuration = new CliConfiguration(rootCommand); | ||
var subsystem = new DiagramSubsystem(); | ||
var args = CliParser.SplitCommandLine(input).ToList().AsReadOnly(); | ||
|
||
Subsystem.Initialize(subsystem, configuration, args); | ||
var parseResult = CliParser.Parse(rootCommand, input, configuration); | ||
var isActive = Subsystem.GetIsActivated(subsystem, parseResult); | ||
|
||
isActive.Should().Be(expectedIsActive); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/System.CommandLine.Subsystems.Tests/DirectiveSubsystemTests.cs
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,41 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using FluentAssertions; | ||
using System.CommandLine.Directives; | ||
using System.CommandLine.Parsing; | ||
using Xunit; | ||
|
||
namespace System.CommandLine.Subsystems.Tests; | ||
|
||
public class DirectiveSubsystemTests | ||
{ | ||
|
||
// For Boolean tests see DiagramSubsystemTests | ||
|
||
[Theory] | ||
[ClassData(typeof(TestData.Directive))] | ||
// TODO: Not sure why these tests are passing | ||
public void String_directive_supplies_string_or_default_and_is_activated_only_when_requested( | ||
string input, bool expectedBoolIsActive, bool expectedStringIsActive, string? expectedValue) | ||
{ | ||
CliRootCommand rootCommand = [new CliCommand("x")]; | ||
var configuration = new CliConfiguration(rootCommand); | ||
var stringSubsystem = new AlternateSubsystems.StringDirectiveSubsystem(); | ||
var boolSubsystem = new AlternateSubsystems.BooleanDirectiveSubsystem(); | ||
var args = CliParser.SplitCommandLine(input).ToList().AsReadOnly(); | ||
|
||
Subsystem.Initialize(stringSubsystem, configuration, args); | ||
Subsystem.Initialize(boolSubsystem, configuration, args); | ||
|
||
var parseResult = CliParser.Parse(rootCommand, input, configuration); | ||
var stringIsActive = Subsystem.GetIsActivated(stringSubsystem, parseResult); | ||
var boolIsActive = Subsystem.GetIsActivated(boolSubsystem, parseResult); | ||
var actualValue = stringSubsystem.Value; | ||
|
||
boolIsActive.Should().Be(expectedBoolIsActive); | ||
stringIsActive.Should().Be(expectedStringIsActive); | ||
actualValue.Should().Be(expectedValue); | ||
|
||
} | ||
} |
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
Oops, something went wrong.