2017-03-03 05:04:03 +00:00
|
|
|
|
// 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;
|
2017-02-03 18:57:57 +00:00
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Microsoft.DotNet.Cli.CommandLine;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Tests
|
|
|
|
|
{
|
|
|
|
|
public class CommandLineApplicationTests
|
|
|
|
|
{
|
|
|
|
|
[Fact]
|
|
|
|
|
public void WhenAnOptionRequiresASingleValueThatIsNotSuppliedItThrowsCommandParsingException()
|
|
|
|
|
{
|
|
|
|
|
var app = new CommandLineApplication();
|
|
|
|
|
|
|
|
|
|
app.Option("-v|--verbosity", "be verbose", CommandOptionType.SingleValue);
|
|
|
|
|
|
|
|
|
|
Action execute = () => app.Execute("-v");
|
|
|
|
|
|
|
|
|
|
execute.ShouldThrow<CommandParsingException>()
|
|
|
|
|
.Which
|
|
|
|
|
.Message
|
|
|
|
|
.Should()
|
2017-06-13 00:31:40 +00:00
|
|
|
|
.Be(string.Format(LocalizableStrings.OptionRequiresSingleValueWhichIsMissing, "-v"));
|
2017-02-03 18:57:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|