GetQueries() public method

Retrieve a list of all the queries supported by the API.
public GetQueries ( ) : string>>>.Task
return string>>>.Task
Ejemplo n.º 1
0
        public async void AvailableQueries_Success()
        {
            var client = new KeenClient(settingsEnv);

            Mock<IQueries> queryMock = null;
            if (UseMocks)
            {
                // A few values that should be present and are unlikely to change
                IEnumerable<KeyValuePair<string,string>> testResult = new List<KeyValuePair<string, string>>() 
                { 
                    new KeyValuePair<string, string>("minimum", "url" ),
                    new KeyValuePair<string, string>("average", "url" ),
                    new KeyValuePair<string, string>("maximum", "url" ),
                    new KeyValuePair<string, string>("count_url", "url" ),
                };

                queryMock = new Mock<IQueries>();
                queryMock.Setup(m=>m.AvailableQueries())
                    .Returns(Task.FromResult(testResult));
                
                client.Queries = queryMock.Object;
            }

            var response = await client.GetQueries();
            Assert.True(response.Any(p => p.Key == "minimum"));
            Assert.True(response.Any(p => p.Key == "average"));
            Assert.True(response.Any(p => p.Key == "maximum"));
            Assert.True(response.Any(p => p.Key == "count_url"));
            if (null != queryMock)
                queryMock.Verify(m => m.AvailableQueries());
        }