public void DoValidAggregationUsingAdapterAndCombiner() { string query = "aggregate(Amount with average as Result)"; var data = TestDataSource.CreateData(); IQueryable <Sales> queryabledata = TestInterceptingProvider.Intercept(data as IQueryable <Sales>, ThrowOnUnImplementedFunctions); IQueryable result = null; "Do aggregation".Given(() => result = RunQuery(query, 3, queryabledata)); "There are results".Then(() => result.Should().NotBeEmpty()); "There are results".Then(() => result.Should().NotBeNull()); "all results have a property called Result".And(() => { var item = result.First(); var t = item.GetType(); t.GetProperty("Result").Should().NotBeNull(); }); "all results have a property called Result".And(() => { var item = result.First(); var t = item.GetType(); var res = t.GetProperty("Result").GetValue(item); Math.Round((double)res, 2).Should().Be(62.86); }); }
public void DoValidAggregationUsingAdapter(string query, double expectedResult) { var data = TestDataSource.CreateData(); IQueryable <Sales> queryabledata = TestInterceptingProvider.Intercept(data as IQueryable <Sales>, ThrowOnUnImplementedFunctions); IQueryable result = null; "Do aggregation".Given(() => result = RunQuery(query, 2000, queryabledata)); "There are results".Then(() => result.Should().NotBeEmpty()); "There are results".Then(() => result.Should().NotBeNull()); "all results have a property called Result".And(() => { var item = result.First(); var t = item.GetType(); t.GetProperty("Result").Should().NotBeNull(); }); "all results are correct".And(() => { var item = result.First(); var t = item.GetType(); var prop = t.GetProperty("Result"); var resultValue = prop.GetValue(item); if (prop.PropertyType == typeof(double)) { Math.Round((double)resultValue, 2).Should().Be(expectedResult); } else { ((int)(resultValue)).Should().Be((int)expectedResult); } }); }
public void DoValidFilterUsingAdapter(string query) { var data = TestDataSource.CreateData(); IQueryable <Sales> queryabledata = TestInterceptingProvider.Intercept(data as IQueryable <Sales>, ThrowOnUnImplementedFunctions); IQueryable result = null; "Do aggregation".Given(() => result = RunQuery(query, 2000, queryabledata)); "There are results".Then(() => result.Should().NotBeEmpty()); "There are results".Then(() => result.Should().NotBeNull()); "results are of type List<Sales>".Then(() => { result.Should().BeOfType <InterceptedQuery <Sales> >(); }); }
public void DoValidGroupByUsingAdapter(string query) { var data = TestDataSource.CreateData(); IQueryable <Sales> queryabledata = TestInterceptingProvider.Intercept(data as IQueryable <Sales>, ThrowOnUnImplementedFunctions); IQueryable result = null; "Do aggregation".Given(() => result = RunQuery(query, 2000, queryabledata)); "There are results".Then(() => result.Should().NotBeEmpty()); "There are results".Then(() => result.Should().NotBeNull()); "Type of results is dynamic generated type".Then( () => result.AllElements().All(x => x.GetType().Namespace == "ODataAggregation.DynamicTypes").Should().BeTrue()); }
public void DoValidGroupByUsingAdapterAndCombiner() { string reason = "everything works great but because our base data is in memory we get an 'System.ArgumentException' when executing it, " + "expression of type 'System.Collections.Generic.IEnumerable`1[System.Web.OData.Aggregation.Tests.Common.Sales]' cannot be used for return type 'System.Linq.IQueryable`1[System.Web.OData.Aggregation.Tests.Common.Sales]'" + "on real queryable this does not happen"; var data = TestDataSource.CreateData(); string query = "groupby(Amount,Id)"; IQueryable <Sales> queryabledata = TestInterceptingProvider.Intercept(data as IQueryable <Sales>, ThrowOnUnImplementedFunctions); IQueryable result = null; Exception ex = null; "Do aggregation".Given(() => ex = Record.Exception(() => result = RunQuery(query, 3, queryabledata))); "System.Reflection.TargetInvocationException Exception is thrown".Then(() => ex.Should().BeOfType <TargetInvocationException>(reason)); }