public void should_join_items_when_to_string_given_all_sub_sfuff() { var select = new SelectInfo() { Items = new List <SelectItem> { new SelectItem { Name = "a" }, new SelectItem { Name = "b", CollectionFilter = FilterInfo.Parse("(c>1)and(d<2)"), CollectionOrder = OrderInfo.Parse("e,f.desc(),g.asc()"), CollectionLimit = new LimitInfo(1, 5), SubItems = new List <SelectItem> { new SelectItem { Name = "h" }, new SelectItem { Name = "i" } } }, new SelectItem { Name = "j" }, } }; select.ToString().Should().Be("a,b{limit(1,5),orderby(e.asc(),f.desc(),g.asc()),where((c > 1) and (d < 2))}(h,i),j"); }
public void should_get_empty_string_when_to_string_given_non_items() { var select = new SelectInfo() { Items = null }; select.ToString().Should().Be(string.Empty); }
public SelectInfo ParseSelectInfo(string text) { if (string.IsNullOrWhiteSpace(text)) { return(null); } var context = new ParseContext(text, this.CurrentCulture); SelectInfo selectInfo = context.ParseSelectInfo(); context.SkipWhiteSpace(); if (context.NotEnd()) { throw ParseErrors.InvalidText(context); } return(selectInfo); }
public void should_join_items_when_to_string_given_simple_items() { var select = new SelectInfo() { Items = new List <SelectItem> { new SelectItem { Name = "a" }, new SelectItem { Name = "b" } } }; select.ToString().Should().Be("a,b"); }
public void should_join_items_when_to_string_given_collection_order() { var select = new SelectInfo() { Items = new List <SelectItem> { new SelectItem { Name = "a" }, new SelectItem { Name = "b", CollectionOrder = OrderInfo.Parse("c,d.desc(),e.asc()") }, new SelectItem { Name = "f" }, } }; select.ToString().Should().Be("a,b{orderby(c.asc(),d.desc(),e.asc())},f"); }
public void should_join_items_when_to_string_given_collection_filter() { var select = new SelectInfo() { Items = new List <SelectItem> { new SelectItem { Name = "a" }, new SelectItem { Name = "b", CollectionFilter = FilterInfo.Parse("c=123") }, new SelectItem { Name = "d" }, } }; select.ToString().Should().Be("a,b{where(c == 123)},d"); }
public void should_join_items_when_to_string_given_collection_limit() { var select = new SelectInfo() { Items = new List <SelectItem> { new SelectItem { Name = "a" }, new SelectItem { Name = "b", CollectionLimit = new LimitInfo(1, 5) }, new SelectItem { Name = "f" }, } }; select.ToString().Should().Be("a,b{limit(1,5)},f"); }
public void should_join_items_when_to_string_given_sub_items() { var select = new SelectInfo() { Items = new List <SelectItem> { new SelectItem { Name = "a" }, new SelectItem { Name = "b", SubItems = new List <SelectItem> { new SelectItem { Name = "c" } } }, new SelectItem { Name = "d" }, } }; select.ToString().Should().Be("a,b(c),d"); }
public void should_return_null_when_parse_empty_string() { SelectInfo.Parse(null).Should().BeNull(); SelectInfo.Parse(string.Empty).Should().BeNull(); SelectInfo.Parse(" \t ").Should().BeNull(); }
private void ParseSelectInfoShouldBe(string inputText, string expected) { SelectInfo.Parse(inputText).ToString().Should().Be(expected); }
public void should_throw_exception_when_parse_invalid_collection_functions(string input) { var action = new Action(() => SelectInfo.Parse(input)); action.Should().ThrowExactly <FilterInfoParseException>(); }