예제 #1
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            // Write aggregators as the ToString form
            IAggregator aggregator = (IAggregator)value;

            writer.WriteValue(aggregator.ToString());
        }
예제 #2
0
        private void AggregatorBaseBehaviors(IAggregator aggregator, bool requiresColumns = true)
        {
            // Verify ToString returns the aggregator type, which matches the start of the class name
            string name = aggregator.ToString();

            Assert.AreEqual(aggregator.GetType().Name.ToLowerInvariant(), (name + "aggregator").ToLowerInvariant());

            // Verify Merge throws if the values are null
            Verify.Exception <ArgumentNullException>(() => aggregator.Merge(null, null));

            // Verify Aggregate throws if the matches or columns are null
            Verify.Exception <ArgumentNullException>(() => aggregator.Aggregate(null, null, new IUntypedColumn[1] {
                ColumnFactory.Build(new ColumnDetails("ID", "int", null), 100)
            }));

            if (requiresColumns)
            {
                ShortSet sample = new ShortSet(100);
                sample.Or(new ushort[] { 1, 2, 3 });
                Verify.Exception <ArgumentException>(() => aggregator.Aggregate(null, sample, null));
            }
        }