public void When_converting_with_select_and_expand_properties_Then_selects_columns_and_maps_expands() { var options = ODataQueryOptionsHelper.Build <TestDTO>("$select=Id,Name,Contact/FirstName,Contact/BirthDate,Contact/Address/City&$expand=Contact,Contact/Address"); var result = this.optionsToSql.ToSelect(options).First(); Assert.That(result.ColumnsList, Is.EquivalentTo(new[] { "Id", "Name", "Contact/FirstName", "Contact/BirthDate", "Contact/Address/City" })); }
public void When_converting_with_select_properties_Then_selects_columns() { var options = ODataQueryOptionsHelper.Build <TestDTO>("$select=Id,Name"); var result = this.optionsToSql.ToSelect(options).First(); Assert.That(result.ColumnsList, Is.EquivalentTo(new[] { "Id", "Name" })); }
public void When_converting_with_top_and_skip_Then_uses_limit_offset() { var options = ODataQueryOptionsHelper.Build <TestDTO>("$top=10&$skip=20"); var result = this.optionsToSql.ToSelect(options).First(); Assert.That(result.LimitClause, Is.EqualTo("10")); Assert.That(result.OffsetClause, Is.EqualTo("20")); }
public void When_converting_with_inline_count_Then_returns_two_selects() { var options = ODataQueryOptionsHelper.Build <TestDTO>("$select=Id,Name&$top=10&$skip=20&$inlinecount=allpages"); var results = this.optionsToSql.ToSelect(options); Assert.That(results, Has.Count.EqualTo(2)); var countSelect = results.Last(); Assert.That(countSelect.ColumnsList, Is.EquivalentTo(new[] { "COUNT(*)" })); Assert.That(countSelect.OffsetClause, Is.Null); Assert.That(countSelect.LimitClause, Is.Null); }
public void When_converting_invalid_columns_Then_throws() { var options = ODataQueryOptionsHelper.Build <TestDTO>("$select=SecretProperty"); Assert.That(() => this.optionsToSql.ToSelect(options), Throws.Exception.InstanceOf <ODataException>()); }