示例#1
0
            public void empty_string_produces_no_conditions()
            {
                var text = string.Empty;

                var actual = CharacterCondition.Parse(text);

                actual.Should().BeEmpty();
            }
示例#2
0
            public void invalid_condition_creates_empty_result()
            {
                var text = "[x";

                var actual = CharacterCondition.Parse(text);

                actual.Should().BeEmpty();
            }
示例#3
0
            public void empty_negated_range_allows_any()
            {
                var text = "[^]";

                var actual = CharacterCondition.Parse(text);

                actual.Should().HaveCount(1);
                actual[0].Characters.Should().BeEmpty();
                actual[0].Restricted.Should().BeTrue();
            }
示例#4
0
            public void multiple_letter_in_brackets_creates_allowed_multiple()
            {
                var text = "[qwerty]";

                var actual = CharacterCondition.Parse(text);

                actual.Should().HaveCount(1);
                actual[0].Characters.ShouldBeEquivalentTo("qwerty".ToCharArray());
                actual[0].Restricted.Should().BeFalse();
            }
示例#5
0
            public void single_letter_in_brackets_creates_single_char()
            {
                var text = "[b]";

                var actual = CharacterCondition.Parse(text);

                actual.Should().HaveCount(1);
                actual[0].Characters.ShouldBeEquivalentTo(new[] { 'b' });
                actual[0].Restricted.Should().BeFalse();
            }
示例#6
0
            public void empty_brackets_creates_disallowed_condition()
            {
                var text = "[]";

                var actual = CharacterCondition.Parse(text);

                actual.Should().HaveCount(1);
                actual[0].Characters.Should().BeEmpty();
                actual[0].Restricted.Should().BeFalse();
            }
示例#7
0
            public void single_dot_allows_anything()
            {
                var text = ".";

                var actual = CharacterCondition.Parse(text);

                actual.Should().HaveCount(1);
                actual[0].Characters.Should().BeEmpty();
                actual[0].Restricted.Should().BeTrue();
            }
示例#8
0
            public void double_caret_negated_range_allows_all_but_caret()
            {
                var text = "[^^]";

                var actual = CharacterCondition.Parse(text);

                actual.Should().HaveCount(1);
                actual[0].Characters.ShouldBeEquivalentTo(new[] { '^' });
                actual[0].Restricted.Should().BeTrue();
            }
示例#9
0
            public void multiple_in_negated_range_allows_all_but_specified()
            {
                var text = "[^qwerty]";

                var actual = CharacterCondition.Parse(text);

                actual.Should().HaveCount(1);
                actual[0].Characters.ShouldBeEquivalentTo("qwerty".ToCharArray());
                actual[0].Restricted.Should().BeTrue();
            }
示例#10
0
            public void single_in_negated_range_allows_all_but_one()
            {
                var text = "[^t]";

                var actual = CharacterCondition.Parse(text);

                actual.Should().HaveCount(1);
                actual[0].Characters.ShouldBeEquivalentTo(new[] { 't' });
                actual[0].Restricted.Should().BeTrue();
            }
示例#11
0
            public void documentation_example_creates_correct_conditions()
            {
                var text = "[^aeiou]y";

                var actual = CharacterCondition.Parse(text);

                actual.Should().HaveCount(2);
                actual[0].Characters.ShouldBeEquivalentTo("aeiou".ToCharArray());
                actual[0].Restricted.Should().BeTrue();
                actual[1].Characters.ShouldBeEquivalentTo(new[] { 'y' });
                actual[1].Restricted.Should().BeFalse();
            }
示例#12
0
            public void two_mixed_ranges_makes_two__restricted_conditions()
            {
                var text = "[qwerty][^asdf]";

                var actual = CharacterCondition.Parse(text);

                actual.Should().HaveCount(2);
                actual[0].Characters.ShouldBeEquivalentTo("qwerty".ToCharArray());
                actual[0].Restricted.Should().BeFalse();
                actual[1].Characters.ShouldBeEquivalentTo("asdf".ToCharArray());
                actual[1].Restricted.Should().BeTrue();
            }