Skip to content

Commit 6fa5385

Browse files
committed
f
1 parent 32e3694 commit 6fa5385

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/Cli.Tests/FeatureFlagTest.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,18 @@ internal sealed class FeatureFlagTest {
1919
private static readonly ISettingsLocationProvider SettingsLocationProvider = new TemporarySettingsLocationProvider();
2020

2121
[Test]
22-
public async Task SettingsControlFlag( [Values( false, true )] bool featureEnabled ) {
22+
public async Task SettingsControlFlag( [Values( false, true, null )] bool? featureEnabled ) {
2323
// Arrange
2424
if ( Directory.Exists( SettingsLocationProvider.GetDirectory() ) ) {
2525
Directory.Delete( SettingsLocationProvider.GetDirectory(), true );
2626
}
2727

28-
new CliSettings { Features = [new FeatureFlagSetting( MyFeature, featureEnabled )] }.Save(
29-
logger: NullLogger.Instance,
30-
location: SettingsLocationProvider
31-
);
28+
var settings = new CliSettings();
29+
if ( featureEnabled != null ) {
30+
settings.Features = [new FeatureFlagSetting( MyFeature, featureEnabled.Value )];
31+
}
32+
33+
settings.Save( logger: NullLogger.Instance, location: SettingsLocationProvider );
3234

3335
RootCommandFactory.CommandRegistration[] customCommands = [
3436
new(typeof(DummyTestCommandHandler), sp => new DummyTestCommand( sp ))
@@ -40,10 +42,12 @@ public async Task SettingsControlFlag( [Values( false, true )] bool featureEnabl
4042
// Assert
4143
using ( Assert.EnterMultipleScope() ) {
4244
Assert.That( result.ExitCode, Is.EqualTo( DummyCommandExitCode ) );
43-
var expectedOutput = featureEnabled ? "Feature is enabled" : "Feature is disabled";
45+
var expectedOutput = featureEnabled == true ? "Feature is enabled" : "Feature is disabled";
4446
Assert.That( result.Output.ToString(), Is.EqualTo( expectedOutput ) );
4547
Assert.That( result.Error.ToString(), Is.Empty );
4648
}
49+
50+
Console.WriteLine( result.Output.ToString() );
4751
}
4852

4953
private sealed class DummyTestCommand( IServiceProvider provider )

0 commit comments

Comments
 (0)