|
4 | 4 | using System.Collections.Generic;
|
5 | 5 | using System.Globalization;
|
6 | 6 | using System.Linq;
|
7 |
| -using Microsoft.FSharp.Core; |
| 7 | + |
8 | 8 | using CommandLine.Core;
|
9 | 9 | using CommandLine.Infrastructure;
|
| 10 | +using CommandLine.Tests.Fakes; |
10 | 11 |
|
11 | 12 | using CSharpx;
|
12 |
| -using CommandLine.Tests.Fakes; |
| 13 | + |
13 | 14 | using FluentAssertions;
|
| 15 | + |
14 | 16 | using Xunit;
|
15 |
| -using System.Reflection; |
16 | 17 |
|
17 | 18 | namespace CommandLine.Tests.Unit.Core
|
18 | 19 | {
|
@@ -1158,6 +1159,42 @@ public void OptionClass_IsImmutable_HasNoCtor()
|
1158 | 1159 | act.Should().Throw<InvalidOperationException>();
|
1159 | 1160 | }
|
1160 | 1161 |
|
| 1162 | + [Fact] |
| 1163 | + public void Options_In_Group_With_No_Values_Generates_MissingGroupOptionError() |
| 1164 | + { |
| 1165 | + // Fixture setup |
| 1166 | + var optionNames = new List<NameInfo> |
| 1167 | + { |
| 1168 | + new NameInfo("", "option1"), |
| 1169 | + new NameInfo("", "option2") |
| 1170 | + }; |
| 1171 | + var expectedResult = new[] { new MissingGroupOptionError("err-group", optionNames) }; |
| 1172 | + |
| 1173 | + // Exercize system |
| 1174 | + var result = InvokeBuild<Options_With_Group>( |
| 1175 | + new[] { "-v 10.42" }); |
| 1176 | + |
| 1177 | + // Verify outcome |
| 1178 | + ((NotParsed<Options_With_Group>)result).Errors.Should().BeEquivalentTo(expectedResult); |
| 1179 | + |
| 1180 | + // Teardown |
| 1181 | + } |
| 1182 | + |
| 1183 | + [Theory] |
| 1184 | + [InlineData("-v", "10.5", "--option1", "test1", "--option2", "test2")] |
| 1185 | + [InlineData("-v", "10.5", "--option1", "test1")] |
| 1186 | + [InlineData("-v", "10.5", "--option2", "test2")] |
| 1187 | + public void Options_In_Group_With_Values_Does_Not_Generate_MissingGroupOptionError(params string[] args) |
| 1188 | + { |
| 1189 | + // Exercize system |
| 1190 | + var result = InvokeBuild<Options_With_Group>(args); |
| 1191 | + |
| 1192 | + // Verify outcome |
| 1193 | + result.Should().BeOfType<Parsed<Options_With_Group>>(); |
| 1194 | + |
| 1195 | + // Teardown |
| 1196 | + } |
| 1197 | + |
1161 | 1198 | private class ValueWithNoSetterOptions
|
1162 | 1199 | {
|
1163 | 1200 | [Value(0, MetaName = "Test", Default = 0)]
|
|
0 commit comments