Exemplo n.º 1
0
        public async void Average_ValidRelativeInterval_Success()
        {
            var client = new KeenClient(settingsEnv);
            var prop = "field1";
            var interval = QueryInterval.EveryNMinutes(5);
            var timeframe = QueryRelativeTimeframe.ThisMinute();
            IEnumerable<QueryIntervalValue<double?>> result =
                new List<QueryIntervalValue<double?>>() { new QueryIntervalValue<double?>((double?)0.0, DateTime.Now.AddMinutes(-5), DateTime.Now) };

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

                client.Queries = queryMock.Object;
            }

            await client.QueryAverageIntervalAsync(testCol, prop, timeframe, interval);

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