public void TryReceiveBehavior() { var block = new WriteOnceBlock <int> (null); int foo; Assert.IsFalse(block.TryReceive(null, out foo)); block.Post(42); Assert.IsTrue(block.TryReceive(null, out foo)); Assert.AreEqual(42, foo); Assert.IsTrue(block.TryReceive(null, out foo)); Assert.IsFalse(block.TryReceive(i => i == 0, out foo)); IList <int> bar; Assert.IsTrue(block.TryReceiveAll(out bar)); Assert.IsNotNull(bar); Assert.AreEqual(1, bar.Count); Assert.AreEqual(42, bar[0]); }
public void TryReceiveBehavior () { var block = new WriteOnceBlock<int> (null); int foo; Assert.IsFalse (block.TryReceive (null, out foo)); block.Post (42); Assert.IsTrue (block.TryReceive (null, out foo)); Assert.AreEqual (42, foo); Assert.IsTrue (block.TryReceive (null, out foo)); Assert.IsFalse (block.TryReceive (i => i == 0, out foo)); IList<int> bar; Assert.IsTrue (block.TryReceiveAll (out bar)); Assert.IsNotNull (bar); Assert.AreEqual (1, bar.Count); Assert.AreEqual (42, bar[0]); }