public void ShouldAddIntegerAggregationWhenParameterIsAvailable()
        {
            var req = new NameValueCollection { { "someInt-granularity", "100s" } };
              var builder = new AggregationBuilder(req);

              builder.MaybeAddIntegerAggregation("someInt");
              Assert.AreEqual(1, builder.ToList().Count);
              Assert.That(builder.ToList()[0], Is.InstanceOf(typeof(IntegerCategoryFunction)));
              Assert.AreEqual(100, ((IntegerCategoryFunction)builder.ToList()[0]).Denominator);
        }
        public void ShouldAddPrefixAggregationWhenParameterIsAvailable()
        {
            var req = new NameValueCollection { { "someString-length", "5" } };
              var builder = new AggregationBuilder(req);

              builder.MaybeAddPrefixAggregation("someString");
              Assert.AreEqual(1, builder.ToList().Count);
              Assert.That(builder.ToList()[0], Is.InstanceOf(typeof(PrefixCategoryFunction)));
              Assert.AreEqual(5, ((PrefixCategoryFunction)builder.ToList()[0]).Length);
        }
        public void ShouldAddDateAggregationWhenParameterIsAvailable()
        {
            var req = new NameValueCollection();
              req.Add("bizDate-granularity", "monthly");
              var builder = new AggregationBuilder(req);

              builder.MaybeAddDateAggregation("bizDate");
              Assert.AreEqual(1, builder.ToList().Count);
              Assert.That(builder.ToList()[0], Is.InstanceOf(typeof(DateCategoryFunction)));
        }
        public void ShouldAddByNameAggregationWhenParameterIsAvailable()
        {
            var req = new NameValueCollection();

            req.Add("someString-granularity", "by-name");
            var builder = new AggregationBuilder(req);

            builder.MaybeAddByNameAggregation("someString");
            Assert.AreEqual(1, builder.ToList().Count);
            Assert.That(builder.ToList()[0], Is.InstanceOf(typeof(ByNameCategoryFunction)));
        }
        public void ShouldAddPrefixAggregationWhenParameterIsAvailable()
        {
            var req = new NameValueCollection {
                { "someString-length", "5" }
            };
            var builder = new AggregationBuilder(req);

            builder.MaybeAddPrefixAggregation("someString");
            Assert.AreEqual(1, builder.ToList().Count);
            Assert.That(builder.ToList()[0], Is.InstanceOf(typeof(PrefixCategoryFunction)));
            Assert.AreEqual(5, ((PrefixCategoryFunction)builder.ToList()[0]).Length);
        }
        public void ShouldAddIntegerAggregationWhenParameterIsAvailable()
        {
            var req = new NameValueCollection {
                { "someInt-granularity", "100s" }
            };
            var builder = new AggregationBuilder(req);

            builder.MaybeAddIntegerAggregation("someInt");
            Assert.AreEqual(1, builder.ToList().Count);
            Assert.That(builder.ToList()[0], Is.InstanceOf(typeof(IntegerCategoryFunction)));
            Assert.AreEqual(100, ((IntegerCategoryFunction)builder.ToList()[0]).Denominator);
        }
        protected override IEnumerable <ICategoryFunction> DetermineAggregations(System.Collections.Specialized.NameValueCollection requestParams)
        {
            var builder = new AggregationBuilder(requestParams);

            builder.MaybeAddDateAggregation("bizDate");
            builder.MaybeAddByNameAggregation("bookId");
            return(builder.ToList());
        }
        public void ShouldNotAddNyNameAggregationForEmptyRequest()
        {
            var req     = new NameValueCollection();
            var builder = new AggregationBuilder(req);

            builder.MaybeAddByNameAggregation("test");
            Assert.AreEqual(0, builder.ToList().Count);
        }
        public void ShouldNotAddDateAggregationWhenDifferentParameterIsAvailable()
        {
            var req = new NameValueCollection();

            req.Add("someString-granularity", "prefix(1)");
            var builder = new AggregationBuilder(req);

            builder.MaybeAddDateAggregation("bizDate");
            Assert.AreEqual(0, builder.ToList().Count);
        }
        public void ShouldNotAddDateAggregationForEmptyRequest()
        {
            var req = new NameValueCollection();
              var builder = new AggregationBuilder(req);

              builder.MaybeAddDateAggregation("test");
              Assert.AreEqual(0, builder.ToList().Count);
        }
        public void ShouldNotAddDateAggregationWhenDifferentParameterIsAvailable()
        {
            var req = new NameValueCollection();
              req.Add("someString-granularity", "prefix(1)");
              var builder = new AggregationBuilder(req);

              builder.MaybeAddDateAggregation("bizDate");
              Assert.AreEqual(0, builder.ToList().Count);
        }
 protected override IEnumerable<ICategoryFunction> DetermineAggregations(System.Collections.Specialized.NameValueCollection requestParams)
 {
     var builder = new AggregationBuilder(requestParams);
       builder.MaybeAddDateAggregation("bizDate");
       builder.MaybeAddByNameAggregation("bookId");
       return builder.ToList();
 }