// 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 System.Linq; using FluentAssertions; using Microsoft.DotNet.Cli; using Microsoft.DotNet.Cli.CommandLine; using Xunit; using Xunit.Abstractions; using Parser = Microsoft.DotNet.Cli.Parser; namespace Microsoft.DotNet.Tests.ParserTests { public class BuildServerShutdownParserTests { private readonly ITestOutputHelper output; public BuildServerShutdownParserTests(ITestOutputHelper output) { this.output = output; } [Fact] public void GivenNoOptionsAllFlagsAreFalse() { var result = Parser.Instance.Parse("dotnet buildserver shutdown"); var options = result["dotnet"]["buildserver"]["shutdown"]; options.ValueOrDefault("msbuild").Should().Be(false); options.ValueOrDefault("vbcscompiler").Should().Be(false); options.ValueOrDefault("razor").Should().Be(false); } [Fact] public void GivenMSBuildOptionIsItTrue() { var result = Parser.Instance.Parse("dotnet buildserver shutdown --msbuild"); var options = result["dotnet"]["buildserver"]["shutdown"]; options.ValueOrDefault("msbuild").Should().Be(true); options.ValueOrDefault("vbcscompiler").Should().Be(false); options.ValueOrDefault("razor").Should().Be(false); } [Fact] public void GivenVBCSCompilerOptionIsItTrue() { var result = Parser.Instance.Parse("dotnet buildserver shutdown --vbcscompiler"); var options = result["dotnet"]["buildserver"]["shutdown"]; options.ValueOrDefault("msbuild").Should().Be(false); options.ValueOrDefault("vbcscompiler").Should().Be(true); options.ValueOrDefault("razor").Should().Be(false); } [Fact] public void GivenRazorOptionIsItTrue() { var result = Parser.Instance.Parse("dotnet buildserver shutdown --razor"); var options = result["dotnet"]["buildserver"]["shutdown"]; options.ValueOrDefault("msbuild").Should().Be(false); options.ValueOrDefault("vbcscompiler").Should().Be(false); options.ValueOrDefault("razor").Should().Be(true); } [Fact] public void GivenMultipleOptionsThoseAreTrue() { var result = Parser.Instance.Parse("dotnet buildserver shutdown --razor --msbuild"); var options = result["dotnet"]["buildserver"]["shutdown"]; options.ValueOrDefault("msbuild").Should().Be(true); options.ValueOrDefault("vbcscompiler").Should().Be(false); options.ValueOrDefault("razor").Should().Be(true); } } }