コード例 #1
0
ファイル: QueryTest.cs プロジェクト: rejahanwer/keen-sdk-net
        public async void SelectUnique_ValidRelativeGroup_Success()
        {
            var client = new KeenClient(settingsEnv);
            var prop = "field1";
            var groupby = "field1";
            var timeframe = QueryRelativeTimeframe.PreviousNDays(5);
            IEnumerable<QueryGroupValue<IEnumerable<string>>> reply = new List<QueryGroupValue<IEnumerable<string>>>()
            {
                new QueryGroupValue<IEnumerable<string>>( new List<string>() { "hello", "goodbye", "I'm late" }, "field1" ),
                new QueryGroupValue<IEnumerable<string>>( new List<string>() { "hello", "goodbye", "I'm late" }, "field1" ),
            };

            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<string>(g => g == groupby),
                        It.Is<QueryRelativeTimeframe>(t => t == timeframe),
                        It.Is<IEnumerable<QueryFilter>>(f => f == null),
                        It.Is<string>(t => t == "")
                        ))
                    .Returns(Task.FromResult(reply));

                client.Queries = queryMock.Object;
            }

            await client.QuerySelectUniqueGroupAsync(testCol, prop, groupby, timeframe, null);

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