public async Task TestConsumeToAccept() { var wob = new WriteOnceBlock <int>(i => i * 2); wob.Post(1); await wob.Completion; var b2 = new BatchedJoinBlock <int, int>(1); wob.LinkTo(b2.Target2, new DataflowLinkOptions { PropagateCompletion = true }); Tuple <IList <int>, IList <int> > item2 = await b2.ReceiveAsync(); Assert.Equal(expected: 0, actual: item2.Item1.Count); Assert.Equal(expected: 1, actual: item2.Item2.Count); b2.Target1.Complete(); var b3 = new BatchedJoinBlock <int, int, int>(1); wob.LinkTo(b3.Target3, new DataflowLinkOptions { PropagateCompletion = true }); Tuple <IList <int>, IList <int>, IList <int> > item3 = await b3.ReceiveAsync(); Assert.Equal(expected: 0, actual: item3.Item1.Count); Assert.Equal(expected: 0, actual: item3.Item2.Count); Assert.Equal(expected: 1, actual: item3.Item3.Count); b3.Target1.Complete(); b3.Target2.Complete(); await Task.WhenAll(b2.Completion, b3.Completion); }
public async Task TestCompletesThroughTargets() { var b2 = new BatchedJoinBlock <int, int>(99); b2.Target1.Post(1); b2.Target1.Complete(); b2.Target2.Complete(); Tuple <IList <int>, IList <int> > item2 = await b2.ReceiveAsync(); Assert.Equal(expected: 1, actual: item2.Item1.Count); Assert.Equal(expected: 0, actual: item2.Item2.Count); await b2.Completion; var b3 = new BatchedJoinBlock <int, int, int>(99); b3.Target2.Post(1); b3.Target3.Complete(); b3.Target2.Complete(); b3.Target1.Complete(); Tuple <IList <int>, IList <int>, IList <int> > item3 = await b3.ReceiveAsync(); Assert.Equal(expected: 0, actual: item3.Item1.Count); Assert.Equal(expected: 1, actual: item3.Item2.Count); Assert.Equal(expected: 0, actual: item3.Item3.Count); await b3.Completion; }
public async Task TestConsumeToAccept() { var wob = new WriteOnceBlock<int>(i => i * 2); wob.Post(1); await wob.Completion; var b2 = new BatchedJoinBlock<int, int>(1); wob.LinkTo(b2.Target2, new DataflowLinkOptions { PropagateCompletion = true }); Tuple<IList<int>, IList<int>> item2 = await b2.ReceiveAsync(); Assert.Equal(expected: 0, actual: item2.Item1.Count); Assert.Equal(expected: 1, actual: item2.Item2.Count); b2.Target1.Complete(); var b3 = new BatchedJoinBlock<int, int, int>(1); wob.LinkTo(b3.Target3, new DataflowLinkOptions { PropagateCompletion = true }); Tuple<IList<int>, IList<int>, IList<int>> item3 = await b3.ReceiveAsync(); Assert.Equal(expected: 0, actual: item3.Item1.Count); Assert.Equal(expected: 0, actual: item3.Item2.Count); Assert.Equal(expected: 1, actual: item3.Item3.Count); b3.Target1.Complete(); b3.Target2.Complete(); await Task.WhenAll(b2.Completion, b3.Completion); }
public async Task TestCompletesThroughBlock() { var b2 = new BatchedJoinBlock<int, int>(99); b2.Target1.Post(1); b2.Complete(); Tuple<IList<int>, IList<int>> item2 = await b2.ReceiveAsync(); Assert.Equal(expected: 1, actual: item2.Item1.Count); Assert.Equal(expected: 0, actual: item2.Item2.Count); await b2.Completion; var b3 = new BatchedJoinBlock<int, int, int>(99); b3.Target3.Post(1); b3.Complete(); Tuple<IList<int>, IList<int>, IList<int>> item3 = await b3.ReceiveAsync(); Assert.Equal(expected: 0, actual: item3.Item1.Count); Assert.Equal(expected: 0, actual: item3.Item2.Count); Assert.Equal(expected: 1, actual: item3.Item3.Count); await b3.Completion; }