public virtual void ActiveEnumeratorTest() { int count = 100; int[] expected = Enumerable.Range(0, count).ToArray(); List <string> actual = new List <string>(); using (IChannel <int> c = new mq.Channel <int>("test-ActiveEnumeratorTest1" + Salt)) using (IChannel <string> w = new mq.Channel <string>("test-ActiveEnumeratorTest2" + Salt)) { w.ActiveEnumerate(p => actual.Add(p)).StoppedEvent += e => { Assert.IsInstanceOfType(e, typeof(ChannelDrainedException)); c.Write(0); }; Task.Factory.StartNew(() => { for (int i = 0; i < count; i++) { w.Write(i.ToString()); } w.Close(); }); c.Read(); Assert.AreEqual(count, actual.Count); CollectionAssert.AreEquivalent(expected.Select(p => p.ToString()).ToArray(), actual); } }