static SamplingMethodsImplementations() { AggregationImplementations <SamplingImplementationBase> .RegisterAggregationImplementation("dayofweek", new DayOfWeekSampling()); AggregationImplementations <SamplingImplementationBase> .RegisterAggregationImplementation("round", new RoundSampling()); AggregationImplementations <SamplingImplementationBase> .RegisterAggregationImplementation("hourofday", new HourOfDaySampling()); }
public void RegisterImplementation() { "dayofweek is registered".Given( () => { AggregationImplementations <SamplingImplementationBase> .RegisterAggregationImplementation( "dayofweek", new DayOfWeekSampling()); }); "when looking for the implementation".When( () => AggregationImplementations <SamplingImplementationBase> .GetAggregationImplementation("dayofweek") .Should() .NotBeNull()); }
public void LookForUnregisteredImplementation() { Exception exception = null; "dayofweek is registered".Given( () => { AggregationImplementations <SamplingImplementationBase> .RegisterAggregationImplementation( "dayofweek", new DayOfWeekSampling()); }); "when looking for the implementation".When( () => exception = Record.Exception(() => AggregationImplementations <SamplingImplementationBase> .GetAggregationImplementation("xxx"))); "unsupported Exception is thrown".Then(() => exception.Should().BeOfType <NotSupportedException>()); }
/// <summary> /// Get the type to use for returning aggregation results in a group-by query. /// </summary> /// <param name="groupByTrasformation">The group by transformation.</param> /// <param name="keyType">The type of a group by key.</param> /// <returns>The new dynamic type.</returns> private Type GetAggregationResultProjectionType(ApplyGroupbyClause groupByTrasformation, Type keyType) { if (groupByTrasformation.Aggregate == null) { throw new ArgumentException("group by without aggregate"); } var keyProperties = new List <Tuple <Type, string> >(); var aggregationImplementation = AggregationImplementations <AggregationImplementationBase> .GetAggregationImplementation(groupByTrasformation.Aggregate.AggregationMethod); var aliasType = aggregationImplementation.GetResultType(Context.ElementClrType, groupByTrasformation.Aggregate); keyProperties.Add(new Tuple <Type, string>(aliasType, groupByTrasformation.Aggregate.Alias)); foreach (var prop in keyType.GetProperties()) { if (prop.Name == "ComparerInstance") { continue; } keyProperties.Add(new Tuple <Type, string>(prop.PropertyType, prop.Name)); } return(AggregationTypesGenerator.CreateType(keyProperties.Distinct(new TypeStringTupleComapere()).ToList(), Context, true)); }