public void Should_read_tags_in_realtime_mode(ConnectionType connectionType) { using (var r = new SerialReader(TestSettings.Instance.GetConnection(connectionType))) { var errors = new List <Exception>(); r.Errors.Subscribe(errors.Add); var tags = new List <Tag>(); r.Tags.Subscribe(tags.Add); r.ActivateOnDemandInventoryMode().Wait(); r.SetRealTimeInventoryParameters(new RealtimeInventoryParams { TagDebounceTime = TimeSpan.Zero }).Wait(); r.ActivateRealtimeInventoryMode().Wait(); new Timing().Context("Could not read 50 tags in 10 seconds").Expect(() => tags.Count > 50); try { r.ActivateOnDemandInventoryMode().Wait(); } catch { } if (errors.Count > 0) { throw errors[0]; } tags[0].Antenna.Should().Be(0); tags[0].Rssi.Should().BeGreaterThan(0); tags[0].DiscoveryTime.Should().BeAfter(DateTime.UtcNow.Date); tags[0].LastSeenTime.Should().BeAfter(DateTime.UtcNow.Date); var aggTags = tags.GroupBy(x => x.TagId) .Select(x => new Tag { TagId = x.Key, ReadCount = x.Count() }) .ToList(); aggTags.Select(x => x.TagId) .Intersect(TestSettings.Instance.GetKnownTagIds) .Count() .Should().BeGreaterOrEqualTo(1, $"Should find at least one tag from known tags list. " + $"Actually found: {string.Join(", ", aggTags.Select(x => x.TagId))}"); } }
static void StartStreaming(SerialReader reader) { reader.Tags.Subscribe(tagStream); reader.Errors.Subscribe(tagStreamErrors); reader.ActivateRealtimeInventoryMode().Wait(); }