Ejemplo n.º 1
0
        protected override async Task ExecuteInnerAsync(IReadOnlyList <string> args, CancellationToken cancellationToken = default)
        {
            if (args.Count >= 1 && args[0].ToLowerInvariant() == "poll")
            {
                await OutputEntitiesAsync(Endpoint.GetObservable(), cancellationToken);

                return;
            }

            await base.ExecuteInnerAsync(args, cancellationToken);
        }
Ejemplo n.º 2
0
        public void TestGetObservable()
        {
            Mock.Expect(HttpMethod.Get, "http://localhost/endpoint")
            .Respond(JsonMime, "{\"id\":1,\"name\":\"test\"}");
            Mock.Expect(HttpMethod.Get, "http://localhost/endpoint")
            .Respond(JsonMime, "{\"id\":2,\"name\":\"test\"}");
            Mock.Expect(HttpMethod.Get, "http://localhost/endpoint")
            .Respond(_ => new HttpResponseMessage
            {
                Content = new StringContent("{\"id\":3,\"name\":\"test\"}", Encoding.UTF8, JsonMime),
                Headers = { RetryAfter = new RetryConditionHeaderValue(TimeSpan.FromSeconds(42)) }
            });

            var observable = _endpoint.GetObservable();

            observable.ToEnumerable().ToList().Should().Equal(
                new MockEntity(1, "test"),
                new MockEntity(2, "test"),
                new MockEntity(3, "test"));
            _endpoint.PollingInterval.Should().Be(TimeSpan.FromSeconds(42));
        }