|
1 |
| -// Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. |
| 1 | +// Copyright 2005-2015 Giacomo Stelluti Scala & Contributors. All rights reserved. See License.md in the project root for license information. |
2 | 2 |
|
3 |
| -using System; |
4 |
| -using System.Collections.Generic; |
5 |
| -using System.Globalization; |
6 |
| -using System.Linq; |
7 | 3 | using Microsoft.FSharp.Core;
|
8 | 4 | using CommandLine.Core;
|
9 | 5 | using CommandLine.Infrastructure;
|
| 6 | +using CommandLine.Tests.Fakes; |
10 | 7 |
|
11 | 8 | using CSharpx;
|
12 |
| -using CommandLine.Tests.Fakes; |
| 9 | + |
13 | 10 | using FluentAssertions;
|
| 11 | + |
| 12 | +using System; |
| 13 | +using System.Collections.Generic; |
| 14 | +using System.Globalization; |
| 15 | +using System.Linq; |
| 16 | + |
14 | 17 | using Xunit;
|
15 | 18 | using System.Reflection;
|
16 | 19 |
|
@@ -1194,6 +1197,47 @@ public void Options_In_Group_With_Values_Does_Not_Generate_MissingGroupOptionErr
|
1194 | 1197 | // Teardown
|
1195 | 1198 | }
|
1196 | 1199 |
|
| 1200 | + [Fact] |
| 1201 | + public void Options_In_Group_WithRequired_Does_Not_Generate_RequiredError() |
| 1202 | + { |
| 1203 | + // Fixture setup |
| 1204 | + var optionNames = new List<NameInfo> |
| 1205 | + { |
| 1206 | + new NameInfo("", "stingvalue"), |
| 1207 | + new NameInfo("s", "shortandlong") |
| 1208 | + }; |
| 1209 | + var expectedResult = new[] { new MissingGroupOptionError("string-group", optionNames) }; |
| 1210 | + |
| 1211 | + // Exercize system |
| 1212 | + var result = InvokeBuild<Simple_Options_With_Required_OptionGroup>(new string[] { "-x" }); |
| 1213 | + |
| 1214 | + // Verify outcome |
| 1215 | + result.Should().BeOfType<NotParsed<Simple_Options_With_Required_OptionGroup>>(); |
| 1216 | + var errors = ((NotParsed<Simple_Options_With_Required_OptionGroup>)result).Errors; |
| 1217 | + |
| 1218 | + errors.Should().HaveCount(1); |
| 1219 | + errors.Should().BeEquivalentTo(expectedResult); |
| 1220 | + } |
| 1221 | + |
| 1222 | + [Fact] |
| 1223 | + public void Options_In_Group_Ignore_Option_Group_If_Option_Group_Name_Empty() |
| 1224 | + { |
| 1225 | + var expectedResult = new[] |
| 1226 | + { |
| 1227 | + new MissingRequiredOptionError(new NameInfo("", "stringvalue")), |
| 1228 | + new MissingRequiredOptionError(new NameInfo("s", "shortandlong")) |
| 1229 | + }; |
| 1230 | + |
| 1231 | + // Exercize system |
| 1232 | + var result = InvokeBuild<Simple_Options_With_OptionGroup_WithDefaultValue>(new string[] { "-x" }); |
| 1233 | + |
| 1234 | + // Verify outcome |
| 1235 | + result.Should().BeOfType<NotParsed<Simple_Options_With_OptionGroup_WithDefaultValue>>(); |
| 1236 | + var errors = ((NotParsed<Simple_Options_With_OptionGroup_WithDefaultValue>)result).Errors; |
| 1237 | + |
| 1238 | + errors.Should().BeEquivalentTo(expectedResult); |
| 1239 | + } |
| 1240 | + |
1197 | 1241 | private class ValueWithNoSetterOptions
|
1198 | 1242 | {
|
1199 | 1243 | [Value(0, MetaName = "Test", Default = 0)]
|
|
0 commit comments