public void ShouldCreateRegisteredAggregator() { StaticBarrier.Run(delegate { CustomAggregators.RegisterAggregator(AggregateName.SUM, typeof(SumAggregator <>)); var aggregator = CustomAggregators.CreateAggregator(AggregateName.SUM, new DefaultAccessor <int>()); Assert.NotNull(aggregator); Assert.IsType <SumAggregator <int> >(aggregator); }); }
public void ShouldSupportMultipleAggregatorRegistrations() { StaticBarrier.Run(delegate { CustomAggregators.RegisterAggregator("any", typeof(SumAggregator <>)); CustomAggregators.RegisterAggregator("any", typeof(MinAggregator <>)); var aggregator = CustomAggregators.CreateAggregator("any", new DefaultAccessor <int>()); Assert.NotNull(aggregator); Assert.IsType <MinAggregator <int> >(aggregator); }); }
public void GlobalSwitch() { StaticBarrier.Run(delegate { var options = new SampleLoadOptions { Filter = new[] { "this", "contains", "A" } }; DataSourceLoadOptionsBase.StringToLowerDefault = false; DataSourceLoader.Load(new[] { "" }, options).data.Cast <object>().ToArray(); Assert.DoesNotContain(options.ExpressionLog, line => line.Contains("ToLower")); }); }
public void CustomAggregator() { StaticBarrier.Run(delegate { CustomAggregators.RegisterAggregator("totalSales", typeof(TotalSalesAggregator <>)); var data = new[] { new Group { items = new[] { new CustomAggregatorDataItem { UnitPrice = 4.04M, Quantity = 5, Discount = 0.10M }, new CustomAggregatorDataItem { UnitPrice = 10.10M, Quantity = 2, Discount = 0.20M } } }, new Group { items = new[] { new CustomAggregatorDataItem { UnitPrice = 15.15M, Quantity = 4, Discount = 0.30M } } }, new Group { items = new CustomAggregatorDataItem[] { } } }; var calculator = new AggregateCalculator <CustomAggregatorDataItem>(data, new DefaultAccessor <CustomAggregatorDataItem>(), new[] { new SummaryInfo { Selector = "this", SummaryType = "totalSales" } }, new[] { new SummaryInfo { Selector = "this", SummaryType = "totalSales" } } ); var totals = calculator.Run(); Assert.Equal(76.76M, totals[0]); Assert.Equal(34.34M, data[0].summary[0]); Assert.Equal(42.42M, data[1].summary[0]); Assert.Equal(0M, data[2].summary[0]); }); }
public void ShouldNotReturnUnexistingAggregator() { StaticBarrier.Run(delegate { Assert.Null(CustomAggregators.CreateAggregator("custom", new DefaultAccessor <int>())); }); }