public static void Asc_and_desc_keywords_may_be_used() { var levels = ColumnAnnotationParser.ParseGroupingLevels("(A asc, B), (C, D desc)").Value; levels.Length.ShouldBe(2); levels[0][0].AscendingOrder.ShouldBeTrue(); levels[1][1].AscendingOrder.ShouldBeFalse(); }
public static void There_can_be_multiple_levels_with_differing_numbers_of_columns() { var levels = ColumnAnnotationParser.ParseGroupingLevels("(B, A), (C), (E, F, D)").Value; levels.Length.ShouldBe(3); levels[0].Select(g => g.FieldName).ShouldBe(new[] { "B", "A" }); levels[1].Select(g => g.FieldName).ShouldBe(new[] { "C" }); levels[2].Select(g => g.FieldName).ShouldBe(new[] { "E", "F", "D" }); }
public static void Asc_and_desc_keywords_may_have_any_casing() { var levels = ColumnAnnotationParser.ParseGroupingLevels("(A ASC, B aSc), (C DESC, D dEsC)").Value; levels.Length.ShouldBe(2); levels[0][0].AscendingOrder.ShouldBeTrue(); levels[0][1].AscendingOrder.ShouldBeTrue(); levels[1][0].AscendingOrder.ShouldBeFalse(); levels[1][1].AscendingOrder.ShouldBeFalse(); }
public static void Field_names_may_contain_digits([Values("A0", "A0A")] string identifier) { var levels = ColumnAnnotationParser.ParseGroupingLevels("(" + identifier + ")").Value; levels.ShouldHaveSingleItem().ShouldHaveSingleItem().FieldName.ShouldBe(identifier); }
public static void Trailing_comma_is_not_allowed_outside_parentheses() { ColumnAnnotationParser.ParseGroupingLevels("(A),").ShouldBe( Result.Error("Expected ‘(’ after comma, but found end of input.")); }
public static void There_can_be_multiple_column_sorts() { ColumnAnnotationParser.ParseSortLevel("B, A").Value.Select(l => l.FieldName) .ShouldBe(new[] { "B", "A" }); }
public static void Blank_string_produces_no_grouping_levels([Values(null, "", " \t\r\n ")] string text) { ColumnAnnotationParser.ParseGroupingLevels(text).Value.ShouldBeEmpty(); }
public static void Default_sort_is_ascending() { var levels = ColumnAnnotationParser.ParseGroupingLevels("(A)").Value; levels[0][0].AscendingOrder.ShouldBeTrue(); }
public static void Field_names_must_not_be_within_parentheses() { ColumnAnnotationParser.ParseSortLevel("(A)").ShouldBe( Result.Error("Expected identifier or end of input at start of input, but found ‘(’.")); }
public static void Field_names_must_not_appear_in_two_different_levels_regardless_of_casing() { ColumnAnnotationParser.ParseGroupingLevels("(a, B), (A, C)").ShouldBe( Result.Error("The field name ‘A’ appears more than once.")); }
public static void Asc_keyword_may_not_be_used_without_a_column_name() { ColumnAnnotationParser.ParseGroupingLevels("(asc)").ShouldBe( Result.Error("Expected identifier after ‘(’, but found keyword ‘asc’.")); }
public static void Desc_keyword_may_not_be_used_before_the_column_name() { ColumnAnnotationParser.ParseSortLevel("desc A").ShouldBe( Result.Error("Expected identifier or end of input at start of input, but found keyword ‘desc’.")); }
public static void Blank_string_produces_no_column_sorts([Values(null, "", " \t\r\n ")] string text) { ColumnAnnotationParser.ParseSortLevel(text).Value.ShouldBeEmpty(); }
public static void Asc_keyword_may_not_be_used_without_a_column_name() { ColumnAnnotationParser.ParseSortLevel("asc").ShouldBe( Result.Error("Expected identifier or end of input at start of input, but found keyword ‘asc’.")); }
public static void Asc_and_desc_keywords_may_not_be_used_for_the_same_column() { ColumnAnnotationParser.ParseSortLevel("A asc desc").ShouldBe( Result.Error("Expected comma or end of input after keyword ‘asc’, but found keyword ‘desc’.")); }
public static void Default_sort_is_ascending() { ColumnAnnotationParser.ParseSortLevel("A").Value[0].AscendingOrder.ShouldBeTrue(); }
public static void Field_names_must_be_separated_with_commas() { ColumnAnnotationParser.ParseSortLevel("A B").ShouldBe( Result.Error("Expected keyword ‘asc’, keyword ‘desc’, comma, or end of input after identifier ‘A’, but found identifier ‘B’.")); }
public static void Field_names_may_not_start_with_digits([Values("0", "0A")] string identifier) { ColumnAnnotationParser.ParseGroupingLevels("(" + identifier + ")").ShouldBe( Result.Error("Unrecognized character ‘0’.")); }
public static void Field_names_must_not_appear_twice_in_the_same_level_regardless_of_casing() { ColumnAnnotationParser.ParseGroupingLevels("(A, B, a)").ShouldBe( Result.Error("The field name ‘a’ appears more than once.")); }
public static void Field_names_must_be_separated_with_commas() { ColumnAnnotationParser.ParseGroupingLevels("(A B)").ShouldBe( Result.Error("Expected keyword ‘asc’, keyword ‘desc’, comma, or ‘)’ after identifier ‘A’, but found identifier ‘B’.")); }
public static void Desc_keyword_may_not_be_used_before_the_column_name() { ColumnAnnotationParser.ParseGroupingLevels("(desc A)").ShouldBe( Result.Error("Expected identifier after ‘(’, but found keyword ‘desc’.")); }
public static void Asc_and_desc_keywords_may_have_any_casing() { ColumnAnnotationParser.ParseSortLevel("A ASC, B aSc, C DESC, D dEsC").Value .Select(l => l.AscendingOrder).ShouldBe(new[] { true, true, false, false }); }
public static void Field_names_must_be_within_parentheses() { ColumnAnnotationParser.ParseGroupingLevels("A").ShouldBe( Result.Error("Expected ‘(’ or end of input at start of input, but found identifier ‘A’.")); }
public static void Desc_keyword_may_not_be_used_on_entire_level() { ColumnAnnotationParser.ParseGroupingLevels("(A) desc").ShouldBe( Result.Error("Expected comma or end of input after ‘)’, but found keyword ‘desc’.")); }
public static void Grouping_levels_must_be_separated_with_commas() { ColumnAnnotationParser.ParseGroupingLevels("(A) (B)").ShouldBe( Result.Error("Expected comma or end of input after ‘)’, but found ‘(’.")); }
public static void Empty_level_is_not_allowed() { ColumnAnnotationParser.ParseGroupingLevels("()").ShouldBe( Result.Error("Expected identifier after ‘(’, but found ‘)’.")); }
public static void Unrecognized_character_is_reported() { ColumnAnnotationParser.ParseGroupingLevels("([A], [B])").ShouldBe( Result.Error("Unrecognized character ‘[’.")); }
public static void Trailing_comma_is_not_allowed_within_parentheses() { ColumnAnnotationParser.ParseGroupingLevels("(A, )").ShouldBe( Result.Error("Expected identifier after comma, but found ‘)’.")); }
public static void Asc_and_desc_keywords_may_not_be_used_for_the_same_column() { ColumnAnnotationParser.ParseGroupingLevels("(A asc desc)").ShouldBe( Result.Error("Expected comma or ‘)’ after keyword ‘asc’, but found keyword ‘desc’.")); }
public static void Unrecognized_character_is_reported() { ColumnAnnotationParser.ParseSortLevel("[A]").ShouldBe( Result.Error("Unrecognized character ‘[’.")); }