Ejemplo n.º 1
0
        public void ConstructAggregationFunctionsTest()
        {
            const String KEY1 = "key1";
            const String KEY2 = "key2";
            const String KEY3 = "key3";
            const String KEY4 = "key4";

            const String EXPECTED_AVERAGE = "avg(key1)";
            const String EXPECTED_COUNT = "count()";
            const String EXPECTED_GROUP = "group(key1,key2,key3)";
            const String EXPECTED_MAX = "max(key1,key2)";
            const String EXPECTED_MIN = "min(key1)";
            const String EXPECTED_SUM = "sum(key1,key2,key3)";
            const String EXPECTED_UNIQUE_SET = "uniqueSet(key1,key2)";
            const String EXPECTED_UNWIND = "unwind(key1,key2,key3,key4)";

            IList<String> expected = new List<String>();
            expected.Add(EXPECTED_AVERAGE);
            expected.Add(EXPECTED_COUNT);
            expected.Add(EXPECTED_GROUP);
            expected.Add(EXPECTED_MAX);
            expected.Add(EXPECTED_MIN);
            expected.Add(EXPECTED_SUM);
            expected.Add(EXPECTED_UNIQUE_SET);
            expected.Add(EXPECTED_UNWIND);

            IStretchrRequest target = new StretchrRequest<String>(new StretchrClient(), response => { }, (request, statusCode, exception) => { });

            target.Average(KEY1)
                  .Count()
                  .Group(KEY1, KEY2, KEY3)
                  .Max(KEY1, KEY2)
                  .Min(KEY1)
                  .Sum(KEY1, KEY2, KEY3)
                  .UniqueSet(KEY1, KEY2)
                  .Unwind(KEY1, KEY2, KEY3, KEY4);

            PrivateObject privateTarget = new PrivateObject(target);

            privateTarget.Invoke("ConstructAggregationFunctions");

            IList<String> actual = (IList<String>)privateTarget.GetField("_queryStringFieldValuesList");

            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.Count, actual.Count);
            Assert.AreEqual(expected[0], actual[0]);
            Assert.AreEqual(expected[1], actual[1]);
            Assert.AreEqual(expected[2], actual[2]);
            Assert.AreEqual(expected[3], actual[3]);
            Assert.AreEqual(expected[4], actual[4]);
            Assert.AreEqual(expected[5], actual[5]);
            Assert.AreEqual(expected[6], actual[6]);
            Assert.AreEqual(expected[7], actual[7]);
        }
Ejemplo n.º 2
0
        public void AverageTest()
        {
            const String KEY1 = "key1";
            const String KEY2 = "key2";
            const String KEY3 = "key3";
            const String KEY4 = "key4";

            IList<String> expected = new List<String>();
            expected.Add(KEY1);
            expected.Add(KEY2);
            expected.Add(KEY3);
            expected.Add(KEY4);

            StretchrRequest<String> target = new StretchrRequest<String>(new StretchrClient(), response => { }, (request, statusCode, exception) => { });
            target.Average(KEY1, KEY2, KEY3, KEY4);

            IList<String> actual = target.AggregationFunctionParameterListAverage;

            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.Count, actual.Count);
            Assert.AreEqual(expected[0], actual[0]);
            Assert.AreEqual(expected[1], actual[1]);
            Assert.AreEqual(expected[2], actual[2]);
            Assert.AreEqual(expected[3], actual[3]);
        }