|
1 |
| -using CommandLine.Core; |
2 |
| -using CommandLine.Tests.Fakes; |
3 |
| -using CSharpx; |
4 |
| -using System.Collections.Generic; |
5 |
| -using Xunit; |
6 |
| - |
7 |
| -namespace CommandLine.Tests.Unit.Core |
8 |
| -{ |
9 |
| - |
10 |
| - public class SpecificationPropertyRulesTests |
11 |
| - { |
12 |
| - [Fact] |
13 |
| - public void Lookup_allows_multi_instance() |
14 |
| - { |
15 |
| - var tokens = new[] |
16 |
| - { |
17 |
| - Token.Name("name"), |
18 |
| - Token.Value("value"), |
19 |
| - Token.Name("name"), |
20 |
| - Token.Value("value2"), |
21 |
| - }; |
22 |
| - |
23 |
| - var specProps = new[] |
24 |
| - { |
25 |
| - SpecificationProperty.Create( |
26 |
| - new OptionSpecification(string.Empty, "name", false, string.Empty, Maybe.Nothing<int>(), Maybe.Nothing<int>(), '\0', Maybe.Nothing<object>(), string.Empty, string.Empty, new List<string>(), typeof(IEnumerable<string>), TargetType.Sequence, string.Empty, flagCounter: false, hidden:false), |
27 |
| - typeof(SequenceOptions).GetProperty(nameof(SequenceOptions.StringSequence)), |
28 |
| - Maybe.Just(new object())), |
29 |
| - }; |
30 |
| - |
31 |
| - var results = specProps.Validate(SpecificationPropertyRules.Lookup(tokens, true)); |
32 |
| - Assert.Empty(results); |
33 |
| - } |
34 |
| - |
35 |
| - [Fact] |
36 |
| - public void Lookup_fails_with_repeated_options_false_multi_instance() |
37 |
| - { |
38 |
| - var tokens = new[] |
39 |
| - { |
40 |
| - Token.Name("name"), |
41 |
| - Token.Value("value"), |
42 |
| - Token.Name("name"), |
43 |
| - Token.Value("value2"), |
44 |
| - }; |
45 |
| - |
46 |
| - var specProps = new[] |
47 |
| - { |
48 |
| - SpecificationProperty.Create( |
49 |
| - new OptionSpecification(string.Empty, "name", false, string.Empty, Maybe.Nothing<int>(), Maybe.Nothing<int>(), '\0', Maybe.Nothing<object>(), string.Empty, string.Empty, new List<string>(), typeof(IEnumerable<string>), TargetType.Sequence, string.Empty, flagCounter: false, hidden:false), |
50 |
| - typeof(SequenceOptions).GetProperty(nameof(SequenceOptions.StringSequence)), |
51 |
| - Maybe.Just(new object())), |
52 |
| - }; |
53 |
| - |
54 |
| - var results = specProps.Validate(SpecificationPropertyRules.Lookup(tokens, false)); |
55 |
| - Assert.Contains(results, r => r.GetType() == typeof(RepeatedOptionError)); |
56 |
| - } |
57 |
| - } |
58 |
| -} |
| 1 | +using CommandLine.Core; |
| 2 | +using CommandLine.Tests.Fakes; |
| 3 | +using CSharpx; |
| 4 | +using System.Collections.Generic; |
| 5 | +using Xunit; |
| 6 | + |
| 7 | +namespace CommandLine.Tests.Unit.Core |
| 8 | +{ |
| 9 | + |
| 10 | + public class SpecificationPropertyRulesTests |
| 11 | + { |
| 12 | + [Fact] |
| 13 | + public void Lookup_allows_multi_instance() |
| 14 | + { |
| 15 | + var tokens = new[] |
| 16 | + { |
| 17 | + Token.Name("name"), |
| 18 | + Token.Value("value"), |
| 19 | + Token.Name("name"), |
| 20 | + Token.Value("value2"), |
| 21 | + }; |
| 22 | + |
| 23 | + var specProps = new[] |
| 24 | + { |
| 25 | + SpecificationProperty.Create( |
| 26 | + new OptionSpecification(string.Empty, "name", false, string.Empty, Maybe.Nothing<int>(), Maybe.Nothing<int>(), '\0', Maybe.Nothing<object>(), string.Empty, string.Empty, new List<string>(), typeof(IEnumerable<string>), TargetType.Sequence, string.Empty), |
| 27 | + typeof(SequenceOptions).GetProperty(nameof(SequenceOptions.StringSequence)), |
| 28 | + Maybe.Just(new object())), |
| 29 | + }; |
| 30 | + |
| 31 | + var results = specProps.Validate(SpecificationPropertyRules.Lookup(tokens, true)); |
| 32 | + Assert.Empty(results); |
| 33 | + } |
| 34 | + |
| 35 | + [Fact] |
| 36 | + public void Lookup_fails_with_repeated_options_false_multi_instance() |
| 37 | + { |
| 38 | + var tokens = new[] |
| 39 | + { |
| 40 | + Token.Name("name"), |
| 41 | + Token.Value("value"), |
| 42 | + Token.Name("name"), |
| 43 | + Token.Value("value2"), |
| 44 | + }; |
| 45 | + |
| 46 | + var specProps = new[] |
| 47 | + { |
| 48 | + SpecificationProperty.Create( |
| 49 | + new OptionSpecification(string.Empty, "name", false, string.Empty, Maybe.Nothing<int>(), Maybe.Nothing<int>(), '\0', Maybe.Nothing<object>(), string.Empty, string.Empty, new List<string>(), typeof(IEnumerable<string>), TargetType.Sequence, string.Empty), |
| 50 | + typeof(SequenceOptions).GetProperty(nameof(SequenceOptions.StringSequence)), |
| 51 | + Maybe.Just(new object())), |
| 52 | + }; |
| 53 | + |
| 54 | + var results = specProps.Validate(SpecificationPropertyRules.Lookup(tokens, false)); |
| 55 | + Assert.Contains(results, r => r.GetType() == typeof(RepeatedOptionError)); |
| 56 | + } |
| 57 | + } |
| 58 | +} |
0 commit comments