public async Task Recover_from_tags_subscriber_error() { Proto.Dispose(); tagStream = new Subject <Tag>(); var p = new AlienReaderProtocol(receiveTimeout: int.MaxValue); p.ConnectAndLogin(Host, Port, "alien", "password").Wait(2000).Should().BeTrue(); p.StartTagPolling(tagStream, errorStream, heartbeatStream).Wait(2000).Should().BeTrue(); var doThrow = false; var badSubscriber = tagStream.Subscribe(x => { if (doThrow) { throw new Exception(); } }); tagStream.Subscribe(tags.Add, ex => throw ex, () => completed = true); await p.Api.AntennaSequence("0"); await new Timing().ExpectAsync(() => tags.Count > 100); errors.Count.Should().Be(0); doThrow = true; await new Timing().ExpectAsync(() => errors.Count > 0); errors[0].Should().BeOfType <Exception>(); tags.Clear(); (await new Timing().Timeout(2000).WaitAsync(() => tags.Count > 0)).Should().BeFalse(); badSubscriber.Dispose(); await new Timing().ExpectAsync(() => tags.Count > 100); }
public async Task Stream_should_continue_after_keepalive_timeout() { await reader.TagStreamKeepAliveTime(1); await reader.AntennaSequence("3"); var tags = new List <Tag>(); var msgs = new List <string>(); await proto.StartTagPolling(tagStream); tagStream.Subscribe(tags.Add); proto.TagPoller.UnparsedMessages.Subscribe(msgs.Add); await reader.AntennaSequence("0"); await Task.Delay(2000); tags.Clear(); (await Timing.StartWait(() => tags.Count > 100)).ShouldBeTrue(); Logger.Debug("{LastSeenTime}", tags.Last().LastSeenTime); (DateTime.Now - tags.Last().LastSeenTime).TotalMinutes.ShouldBeLessThan(1); (await reader.AntennaSequence("3")).ShouldBe("3"); (await Timing.StartWait(() => (DateTime.Now - tags.Last().LastSeenTime).TotalSeconds > 1) ).ShouldBeTrue(); await Task.Delay(2000); tags.Clear(); await reader.AntennaSequence("0"); (await Timing.StartWait(() => tags.Count > 100)).ShouldBeTrue(); msgs.ForEach(x => Logger.Error(x)); msgs.Count.ShouldBe(0); }
public TagStreamListenerTests() { sim = new SimulatorListener(); proto = new AlienReaderProtocol(receiveTimeout: int.MaxValue); proto.ConnectAndLogin(sim.Host, sim.Port, "alien", "password").Wait(2000).ShouldBeTrue(); proto.StartTagPolling(tagStream).Wait(2000).ShouldBeTrue(); reader = proto.Api; tagStream.Subscribe(tags.Add, ex => throw ex, () => completed = true); proto.TagPoller.UnparsedMessages.Subscribe(msgs.Add); }