示例#1
0
        public TagStreamListenerTests()
        {
            SetTagListHandlerForKnownTags();

            Proto.StartTagPolling(tagStream, errorStream, heartbeatStream).Wait(2000).Should().BeTrue();
            heartbeatStream.Subscribe(heartbeats.Add);
            tagStream.Subscribe(tags.Add, ex => throw ex, () => completed = true);
            errorStream.Where(x => !(x is ObjectDisposedException)).Subscribe(errors.Add);
            Proto.TagPoller.UnparsedMessages.Subscribe(msgs.Add);
        }
示例#2
0
        public async Task Stream_should_continue_after_keepalive_timeout()
        {
            if (!Settings.UseHardwareReader)
            {
                return;
            }
            SetTagListHandlerForKnownTags();
            await Proto.Api.TagStreamKeepAliveTime(1);

            await Proto.Api.AntennaSequence("3");

            var tags   = new List <Tag>();
            var msgs   = new List <string>();
            var errors = new List <Exception>();
            await Proto.StartTagPolling(tagStream, errorStream, heartbeatStream);

            tagStream.Subscribe(tags.Add);
            errorStream.Subscribe(errors.Add);
            Proto.TagPoller.UnparsedMessages.Subscribe(msgs.Add);
            await Proto.Api.AntennaSequence("0");

            await Task.Delay(2000);

            tags.Clear();
            await new Timing().ExpectAsync(() => tags.Count > 100);
            Logger.Debug("{LastSeenTime}", tags.Last().LastSeenTime);
            (DateTime.UtcNow - tags.Last().LastSeenTime).TotalMinutes.Should().BeLessThan(1);
            (await Proto.Api.AntennaSequence("3")).Should().Be("3");
            await new Timing()
            .FailureDetails(() => $"Now: {DateTime.UtcNow}, Actual: {tags.Last().LastSeenTime}")
            .ExpectAsync(() => (DateTime.UtcNow - tags.Last().LastSeenTime).TotalSeconds > 1);
            await Task.Delay(2000);

            tags.Clear();
            await Proto.Api.AntennaSequence("0");

            await new Timing().ExpectAsync(() => tags.Count > 100);
            msgs.ForEach(x => Logger.Error(x));
            msgs.Count.Should().Be(0);
        }