BadScript 2
Loading...
Searching...
No Matches
SpecificationPropertyRulesTests.cs
Go to the documentation of this file.
3using CSharpx;
4using System.Collections.Generic;
5using Xunit;
6
8{
9
11 {
12 [Fact]
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 {
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]
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 {
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}
The Maybe type models an optional value. A value of type Maybe a either contains a value of type a (r...
Definition Maybe.cs:33
static SpecificationProperty Create(Specification specification, PropertyInfo property, Maybe< object > value)
static IEnumerable< Func< IEnumerable< SpecificationProperty >, IEnumerable< Error > > > Lookup(IEnumerable< Token > tokens)
static Token Value(string text)
Definition Token.cs:30
static Token Name(string text)
Definition Token.cs:25
Models an error generated when an option is repeated two or more times.
Definition Error.cs:436
IEnumerable< string > StringSequence
Definition Verb_Fakes.cs:71