dotnet-installer/test/dotnet.Tests/ParserTests/BuildServerShutdownParserTests.cs
Peter Huene 3488a84c35
Implement buildserver shutdown command.
This commit implements the `buildserver shutdown` command that can be used to
shutdown MSBuild, VB/C# compiler, and Razor build servers.

By default, all three build servers are shut down.  Options can be passed to
shut down a subset of the build servers.

Fixes #8185.
2018-03-30 15:13:52 -07:00

78 lines
2.9 KiB
C#

// 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<bool>("msbuild").Should().Be(false);
options.ValueOrDefault<bool>("vbcscompiler").Should().Be(false);
options.ValueOrDefault<bool>("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<bool>("msbuild").Should().Be(true);
options.ValueOrDefault<bool>("vbcscompiler").Should().Be(false);
options.ValueOrDefault<bool>("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<bool>("msbuild").Should().Be(false);
options.ValueOrDefault<bool>("vbcscompiler").Should().Be(true);
options.ValueOrDefault<bool>("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<bool>("msbuild").Should().Be(false);
options.ValueOrDefault<bool>("vbcscompiler").Should().Be(false);
options.ValueOrDefault<bool>("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<bool>("msbuild").Should().Be(true);
options.ValueOrDefault<bool>("vbcscompiler").Should().Be(false);
options.ValueOrDefault<bool>("razor").Should().Be(true);
}
}
}