Esempio n. 1
0
        public async void SelectUnique_ValidFilter_Success()
        {
            var client = new KeenClient(settingsEnv);
            var prop = "field1";
            var filters = new List<QueryFilter>() { new QueryFilter("field1", QueryFilter.FilterOperator.GreaterThan(), "1") };
            IEnumerable<string> result = new List<string>() { "hello", "goodbye", "I'm late" };

            Mock<IQueries> queryMock = null;
            if (UseMocks)
            {
                queryMock = new Mock<IQueries>();
                queryMock.Setup(m => m.Metric<IEnumerable<string>>(
                      It.Is<string>(me => me == "select_unique"),
                      It.Is<string>(c => c == testCol),
                      It.Is<string>(p => p == prop),
                      It.Is<QueryRelativeTimeframe>(t => t == null),
                      It.Is<IEnumerable<QueryFilter>>(f => f == filters),
                      It.Is<string>(t => t == "")
                      ))
                  .Returns(Task.FromResult(result));

                client.Queries = queryMock.Object;
            }

            await client.QuerySelectUniqueAsync(testCol, prop, null, filters);

            if (null != queryMock)
                queryMock.VerifyAll();
        }
Esempio n. 2
0
        public async void SelectUnique_ValidAbsolute_Success()
        {
            var client = new KeenClient(settingsEnv);
            var timeframe = new QueryAbsoluteTimeframe(DateTime.Now.AddDays(-1), DateTime.Now);
            var prop = "field1";
            IEnumerable<string> result = new List<string>() { "hello", "goodbye", "I'm late" };

            Mock<IQueries> queryMock = null;
            if (UseMocks)
            {
                queryMock = new Mock<IQueries>();
                queryMock.Setup(m => m.Metric<IEnumerable<string>>(
                        It.Is<string>(me => me == "select_unique"),
                        It.Is<string>(c => c == testCol),
                        It.Is<string>(p => p == prop),
                        It.Is<QueryAbsoluteTimeframe>(t => t == timeframe),
                        It.Is<IEnumerable<QueryFilter>>(f => f == null),
                        It.Is<string>(t => t == "")
                        ))
                    .Returns(Task.FromResult(result));

                client.Queries = queryMock.Object;
            }

            var reply = await client.QuerySelectUniqueAsync(testCol, prop, timeframe);

            if (null != queryMock)
                queryMock.VerifyAll();
        }