Esempio n. 1
0
 public void test_NumberAvg()
 {
     FillMap <float>();
     FillMap <double>();
     Assert.AreEqual(4.5d, map.Aggregate(Aggregators.NumberAvg()));
     Assert.AreEqual(4.5d, map.Aggregate(Aggregators.NumberAvg("this")));
 }
        public async Task Test_NumberAvg()
        {
            // .NET does not have a 'number' type, so we have to use 'object'

            var dictionary = await Client.GetMapAsync <string, object>(CreateUniqueName());

            await using var _ = DestroyAndDispose(dictionary);

            await Fill(dictionary, i => (float)i);
            await Fill(dictionary, i => (double)i);
            await Fill(dictionary, i => (int)i);
            await Fill(dictionary, i => (long)i);

            Assert.AreEqual(4.5d, await dictionary.AggregateAsync(Aggregators.NumberAvg()));
            Assert.AreEqual(4.5d, await dictionary.AggregateAsync(Aggregators.NumberAvg("this")));
        }
Esempio n. 3
0
        public void Tests()
        {
            AssertAggregator((CountAggregator)Aggregators.Count("name"), AggregatorDataSerializerHook.Count);

            AssertAggregator((BigIntegerSumAggregator)Aggregators.BigIntegerSum("name"), AggregatorDataSerializerHook.BigIntSum);
            AssertAggregator((DoubleSumAggregator)Aggregators.DoubleSum("name"), AggregatorDataSerializerHook.DoubleSum);
            AssertAggregator((FixedSumAggregator)Aggregators.FixedPointSum("name"), AggregatorDataSerializerHook.FixedSum);
            AssertAggregator((LongSumAggregator)Aggregators.LongSum("name"), AggregatorDataSerializerHook.LongSum);
            AssertAggregator((FloatingPointSumAggregator)Aggregators.FloatingPointSum("name"), AggregatorDataSerializerHook.FloatingPointSum);
            AssertAggregator((IntegerSumAggregator)Aggregators.IntegerSum("name"), AggregatorDataSerializerHook.IntSum);

            AssertAggregator((NumberAverageAggregator)Aggregators.NumberAvg("name"), AggregatorDataSerializerHook.NumberAvg);
            AssertAggregator((DoubleAverageAggregator)Aggregators.DoubleAvg("name"), AggregatorDataSerializerHook.DoubleAvg);
            AssertAggregator((IntegerAverageAggregator)Aggregators.IntegerAvg("name"), AggregatorDataSerializerHook.IntAvg);
            AssertAggregator((LongAverageAggregator)Aggregators.LongAvg("name"), AggregatorDataSerializerHook.LongAvg);

            AssertAggregator((MaxAggregator <int>)Aggregators.Max <int>("name"), AggregatorDataSerializerHook.Max);
            AssertAggregator((MinAggregator <int>)Aggregators.Min <int>("name"), AggregatorDataSerializerHook.Min);

            AssertAggregator((CountAggregator)Aggregators.Count(), AggregatorDataSerializerHook.Count);

            AssertAggregator((BigIntegerSumAggregator)Aggregators.BigIntegerSum(), AggregatorDataSerializerHook.BigIntSum);
            AssertAggregator((DoubleSumAggregator)Aggregators.DoubleSum(), AggregatorDataSerializerHook.DoubleSum);
            AssertAggregator((FixedSumAggregator)Aggregators.FixedPointSum(), AggregatorDataSerializerHook.FixedSum);
            AssertAggregator((LongSumAggregator)Aggregators.LongSum(), AggregatorDataSerializerHook.LongSum);
            AssertAggregator((FloatingPointSumAggregator)Aggregators.FloatingPointSum(), AggregatorDataSerializerHook.FloatingPointSum);
            AssertAggregator((IntegerSumAggregator)Aggregators.IntegerSum(), AggregatorDataSerializerHook.IntSum);

            AssertAggregator((NumberAverageAggregator)Aggregators.NumberAvg(), AggregatorDataSerializerHook.NumberAvg);
            AssertAggregator((DoubleAverageAggregator)Aggregators.DoubleAvg(), AggregatorDataSerializerHook.DoubleAvg);
            AssertAggregator((IntegerAverageAggregator)Aggregators.IntegerAvg(), AggregatorDataSerializerHook.IntAvg);
            AssertAggregator((LongAverageAggregator)Aggregators.LongAvg(), AggregatorDataSerializerHook.LongAvg);

            AssertAggregator((MaxAggregator <int>)Aggregators.Max <int>(), AggregatorDataSerializerHook.Max);
            AssertAggregator((MinAggregator <int>)Aggregators.Min <int>(), AggregatorDataSerializerHook.Min);
        }