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 ShouldNotAddDateAggregationForEmptyRequest()
        {
            var req     = new NameValueCollection();
            var builder = new AggregationBuilder(req);

            builder.MaybeAddDateAggregation("test");
            Assert.AreEqual(0, builder.ToList().Count);
        }
        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 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 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 ShouldInvalidGranularityExceptionWhenGranularityValueIsBad()
        {
            var req = new NameValueCollection();

            req.Add("bizDate-granularity", "invalid");
            var builder = new AggregationBuilder(req);

            try {
                builder.MaybeAddDateAggregation("bizDate");
                Assert.Fail("Should have thrown InvalidGranularityException");
            } catch (InvalidGranularityException ex) {
                Assert.AreEqual("The aggregation value 'invalid' is not valid for the field 'bizDate'", ex.Message);
            }
        }
        public void ShouldNotAddDateAggregationForEmptyRequest()
        {
            var req = new NameValueCollection();
              var builder = new AggregationBuilder(req);

              builder.MaybeAddDateAggregation("test");
              Assert.AreEqual(0, builder.ToList().Count);
        }
        public void ShouldInvalidGranularityExceptionWhenGranularityValueIsBad()
        {
            var req = new NameValueCollection();
              req.Add("bizDate-granularity", "invalid");
              var builder = new AggregationBuilder(req);

              try {
            builder.MaybeAddDateAggregation("bizDate");
            Assert.Fail("Should have thrown InvalidGranularityException");
              } catch (InvalidGranularityException ex) {
            Assert.AreEqual("The aggregation value 'invalid' is not valid for the field 'bizDate'", ex.Message);
              }
        }
        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();
 }