예제 #1
0
        public async Task QueryRaw()
        {
            MockServer.Given(Request.Create().WithPath("/api/v2/query").UsingPost())
            .RespondWith(CreateResponse());

            var result = await FluxClient.QueryRaw("from(bucket:\"telegraf\")");

            AssertSuccessResult(result);
        }
예제 #2
0
        public async Task QueryRawCallbackOnError()
        {
            MockServer.Stop();

            await FluxClient.QueryRaw("from(bucket:\"telegraf\")",
                                      (cancellable, result) => Assert.Fail("Unreachable"),
                                      error => CountdownEvent.Signal());

            WaitToCallback();
        }
        public async Task QueryError()
        {
            MockServer.Given(Request.Create().WithPath("/api/v2/query").UsingPost())
            .RespondWith(CreateErrorResponse("Flux query is not valid"));

            try
            {
                await FluxClient.QueryRaw("from(bucket:\"telegraf\")");

                Assert.Fail();
            }
            catch (InfluxException e)
            {
                Assert.That(e.Message.Equals("Flux query is not valid"));
            }
        }
예제 #4
0
        public async Task QueryRawCallbackOnComplete()
        {
            CountdownEvent = new CountdownEvent(1);

            MockServer.Given(Request.Create().WithPath("/api/v2/query").UsingPost())
            .RespondWith(CreateResponse());

            var results = new List <string>();

            await FluxClient.QueryRaw("from(bucket:\"telegraf\")", null,
                                      (cancellable, result) => results.Add(result),
                                      error => Assert.Fail("Unreachable"),
                                      () => CountdownEvent.Signal());

            WaitToCallback();
            AssertSuccessResult(string.Join("\n", results));
        }
예제 #5
0
        public async Task QueryRawCallback()
        {
            CountdownEvent = new CountdownEvent(8);

            MockServer.Given(Request.Create().WithPath("/api/v2/query").UsingPost())
            .RespondWith(CreateResponse());

            var results = new List <string>();

            await FluxClient.QueryRaw("from(bucket:\"telegraf\")",
                                      (cancellable, result) =>
            {
                results.Add(result);
                CountdownEvent.Signal();
            });

            WaitToCallback();

            Assert.That(results.Count == 8);
            AssertSuccessResult(string.Join("\n", results));
        }