public async Task Reconnection_check() { if (!Settings.UseHardwareReader) { return; } var r = new ReconnectingAlienReaderProtocol(new DnsEndPoint(Host, Port), async api => { await api.AntennaSequence("0"); await api.TagListAntennaCombine(false); await api.AcqG2AntennaCombine(false); await api.RFAttenuation(100); await api.Time(DateTime.UtcNow); }); r.ReconnectTimeout = 2000; var status = new List <bool>(); var tags = new List <Tag>(); r.Connected.Subscribe(status.Add); r.Tags.Subscribe(tags.Add); new Timing().Expect(() => tags.Count > 0); status.LastOrDefault().Should().BeTrue(); await r.Current.Api.Reboot(); new Timing().Expect(() => (DateTime.UtcNow - tags.Last().LastSeenTime).TotalSeconds > 5); tags.Clear(); r.IsConnected.Should().BeFalse(); status.Last().Should().BeFalse(); //Timing.StartWait(() => status.Last(), (int)(AlienReaderProtocol.DefaultReceiveTimeout * 2.5)).Result.Should().BeTrue(); new Timing().Timeout(90000).Expect(() => tags.Count > 0); }
public async Task Reconnection_check() { if (!sim.UsePhysicalDevice) { return; } var r = new ReconnectingAlienReaderProtocol(new IPEndPoint(IPAddress.Parse(sim.Host), sim.Port), async api => { await api.AntennaSequence("0"); await api.RFModulation(RFModulation.HS); await api.TagListAntennaCombine(false); await api.AcqG2AntennaCombine(false); await api.RFAttenuation(100); }); r.ReconnectTimeout = 2000; var status = new List <ConnectionStatus>(); var tags = new List <Tag>(); r.ConnectionStatus.Subscribe(status.Add); r.Tags.Subscribe(tags.Add); Timing.StartWait(() => tags.Count > 0).Result.ShouldBeTrue(); status.OfType <DisconnectedEvent>().Count().ShouldBe(0); status.OfType <FailedToConnect>().Count().ShouldBe(0); await r.Current.Api.Reboot(); Timing.StartWait(() => (DateTimeOffset.UtcNow - tags.Last().LastSeenTime).TotalSeconds > 5).Result.ShouldBeTrue(); tags.Clear(); r.IsConnected.ShouldBeFalse(); status.OfType <DisconnectedEvent>().Count().ShouldBeGreaterThan(0); Timing.StartWait(() => status.OfType <FailedToConnect>().Any(), (int)(AlienReaderProtocol.DefaultReceiveTimeout * 2.5)).Result.ShouldBeTrue(); Timing.StartWait(() => tags.Count > 0, 60000).Result.ShouldBeTrue(); }