Ejemplo n.º 1
0
        public async void Count_ValidRelativeInterval_Success()
        {
            var client = new KeenClient(settingsEnv);
            var interval = QueryInterval.EveryNMinutes(5);
            var timeframe = QueryRelativeTimeframe.ThisMinute();
            IEnumerable<QueryIntervalValue<int>> result =
                new List<QueryIntervalValue<int>>() { new QueryIntervalValue<int>(0, DateTime.Now.AddMinutes(-5), DateTime.Now) };

            Mock<IQueries> queryMock = null;
            if (UseMocks)
            {
                queryMock = new Mock<IQueries>();
                queryMock.Setup(m => m.Metric<int>(
                        It.Is<string>(me => me == "count"),
                        It.Is<string>(c => c == testCol),
                        It.Is<string>(p => p == "-"),
                        It.Is<QueryTimeframe>(t => t == timeframe),
                        It.Is<QueryInterval>(i => i == interval),
                        It.Is<IEnumerable<QueryFilter>>(f => f == null),
                        It.Is<string>(z => z == "")))
                    .Returns(Task.FromResult(result));

                client.Queries = queryMock.Object;
            }

            var counts = await client.QueryCountIntervalAsync(testCol, timeframe, interval);
            Assert.IsNotNull(counts);

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