public void RunBatchBlockTests() { Assert.True(IDataflowBlockTestHelper.TestToString(nameFormat => nameFormat != null ? new BatchBlock <int>(1, new GroupingDataflowBlockOptions() { NameFormat = nameFormat }) : new BatchBlock <int>(1))); Assert.True(ISourceBlockTestHelper.TestLinkTo <int[]>(ConstructBatchNewWithNMessages(1), 1)); Assert.True(ISourceBlockTestHelper.TestReserveMessageAndReleaseReservation <int[]>(ConstructBatchNewWithNMessages(1))); Assert.True(ISourceBlockTestHelper.TestConsumeMessage <int[]>(ConstructBatchNewWithNMessages(1))); Assert.True(ISourceBlockTestHelper.TestTryReceiveWithFilter <int[]>(ConstructBatchNewWithNMessages(1), 1)); Assert.True(ISourceBlockTestHelper.TestTryReceiveAll <int[]>(ConstructBatchNewWithNMessages(1), 1)); Assert.True(ISourceBlockTestHelper.TestCancelWhileReserve(ct => new BatchBlock <int>(1, new GroupingDataflowBlockOptions { CancellationToken = ct }), source => (source as BatchBlock <int>).Post(0), source => (source as BatchBlock <int>).OutputCount)); Assert.True(ITargetBlockTestHelper.TestOfferMessage <int>(new BatchBlock <int>(1))); Assert.True(ITargetBlockTestHelper.TestPost <int>(new BatchBlock <int>(1))); Assert.True(ITargetBlockTestHelper.TestComplete <int>(new BatchBlock <int>(1))); Assert.True(ITargetBlockTestHelper.TestCompletionTask <int>(new BatchBlock <int>(1))); Assert.True(ITargetBlockTestHelper.TestNonGreedyPost(new BatchBlock <int>(1, new GroupingDataflowBlockOptions { Greedy = false }))); Assert.True(TestReleaseOnReserveException(linkBadFirst: true)); Assert.True(TestReleaseOnReserveException(linkBadFirst: false)); Assert.True(TestMaxNumberOfGroups(greedy: true, sync: true)); Assert.True(TestMaxNumberOfGroups(greedy: true, sync: false)); // {non-greedy sync} is intentioanlly skipped because it is not supported by the block Assert.True(TestMaxNumberOfGroups(greedy: false, sync: false)); Assert.True(TestTriggerBatch(boundedCapacity: DataflowBlockOptions.Unbounded)); Assert.True(TestTriggerBatchRacingWithSendAsync(greedy: true)); Assert.True(TestTriggerBatchRacingWithSendAsync(greedy: false)); Assert.True(TestTriggerBatchRacingWithComplete(greedy: true)); Assert.True(TestTriggerBatchRacingWithComplete(greedy: false)); }
public void RunBroadcastBlockTests() { Assert.True(IDataflowBlockTestHelper.TestToString(nameFormat => nameFormat != null ? new BroadcastBlock <int>(null, new DataflowBlockOptions() { NameFormat = nameFormat }) : new BroadcastBlock <int>(null))); Assert.True(ISourceBlockTestHelper.TestLinkTo <int>(ConstructBroadcastNewWithNMessages(1), 1)); Assert.True(ISourceBlockTestHelper.TestReserveMessageAndReleaseReservation <int>(ConstructBroadcastNewWithNMessages(1))); Assert.True(ISourceBlockTestHelper.TestConsumeMessage <int>(ConstructBroadcastNewWithNMessages(1))); Assert.True(ISourceBlockTestHelper.TestTryReceiveWithFilter <int>(ConstructBroadcastNewWithNMessages(1), 1)); Assert.True(ISourceBlockTestHelper.TestTargetOrder <int>(new BroadcastBlock <int>(i => i), 1)); Assert.True(ITargetBlockTestHelper.TestPost <int>(new BroadcastBlock <int>(i => i))); Assert.True(ITargetBlockTestHelper.TestCompletionTask <int>(new BroadcastBlock <int>(i => i))); }
public void RunBatchedJoinBlockTests() { // BatchedJoinBlock`2 Assert.True(IDataflowBlockTestHelper.TestToString(nameFormat => nameFormat != null ? new BatchedJoinBlock <int, int>(1, new GroupingDataflowBlockOptions() { NameFormat = nameFormat }) : new BatchedJoinBlock <int, int>(1))); Assert.True(ISourceBlockTestHelper.TestLinkTo <Tuple <IList <int>, IList <int> > >(ConstructBatchedJoin2NewWithNMessages(1), 1)); Assert.True(ISourceBlockTestHelper.TestReserveMessageAndReleaseReservation <Tuple <IList <int>, IList <int> > >(ConstructBatchedJoin2NewWithNMessages(1))); //Assert.True(ISourceBlockTestHelper.TestReleaseReservation<Tuple<IList<int>, IList<int>>>(ConstructBatchedJoin2NewWithNMessages(1))); // BatchedJoinBlock`3 Assert.True(ISourceBlockTestHelper.TestConsumeMessage <Tuple <IList <int>, IList <int>, IList <int> > >(ConstructBatchedJoin3NewWithNMessages(1))); Assert.True(ISourceBlockTestHelper.TestTryReceiveWithFilter <Tuple <IList <int>, IList <int>, IList <int> > >(ConstructBatchedJoin3NewWithNMessages(1), 1)); Assert.True(ISourceBlockTestHelper.TestTryReceiveAll <Tuple <IList <int>, IList <int>, IList <int> > >(ConstructBatchedJoin3NewWithNMessages(1), 1)); }
public void RunTransformManyBlockTests() { Assert.True(IDataflowBlockTestHelper.TestToString(nameFormat => nameFormat != null ? new TransformManyBlock <int, int>(x => new int[] { x }, new ExecutionDataflowBlockOptions() { NameFormat = nameFormat }) : new TransformManyBlock <int, int>(x => new int[] { x }))); Assert.True(ISourceBlockTestHelper.TestLinkTo <int>(ConstructTransformManyWithNMessages(2), 1)); Assert.True(ISourceBlockTestHelper.TestReserveMessageAndReleaseReservation <int>(ConstructTransformManyWithNMessages(1))); Assert.True(ISourceBlockTestHelper.TestConsumeMessage <int>(ConstructTransformManyWithNMessages(1))); Assert.True(ISourceBlockTestHelper.TestTryReceiveWithFilter <int>(ConstructTransformManyWithNMessages(1), 1)); Assert.True(ISourceBlockTestHelper.TestTryReceiveAll <int>(ConstructTransformManyWithNMessages(1), 1)); Assert.True(ITargetBlockTestHelper.TestOfferMessage <int>(new TransformManyBlock <int, int>(i => new int[] { i }))); Assert.True(ITargetBlockTestHelper.TestPost <int>(new TransformManyBlock <int, int>(i => new int[] { i }))); Assert.True(ITargetBlockTestHelper.TestComplete <int>(new TransformManyBlock <int, int>(i => new int[] { i }))); Assert.True(ITargetBlockTestHelper.TestCompletionTask <int>(new TransformManyBlock <int, int>(i => new int[] { i }))); Assert.True(ITargetBlockTestHelper.TestNonGreedyPost(new TransformManyBlock <int, int>(x => { Task.Delay(500).Wait(); return(new int[] { x }); }, new ExecutionDataflowBlockOptions { BoundedCapacity = 1 }))); }
public void RunJoinBlockTests() { Assert.True(IDataflowBlockTestHelper.TestToString(nameFormat => nameFormat != null ? new JoinBlock <int, int>(new GroupingDataflowBlockOptions() { NameFormat = nameFormat }) : new JoinBlock <int, int>())); Assert.True(IDataflowBlockTestHelper.TestToString(nameFormat => nameFormat != null ? new JoinBlock <int, int, int>(new GroupingDataflowBlockOptions() { NameFormat = nameFormat }) : new JoinBlock <int, int, int>())); Assert.True(ISourceBlockTestHelper.TestLinkTo <Tuple <int, int> >(ConstructJoinNewWithNMessages(2), 1)); Assert.True(ISourceBlockTestHelper.TestReserveMessageAndReleaseReservation <Tuple <int, int> >(ConstructJoinNewWithNMessages(1))); //Assert.True(ISourceBlockTestHelper.TestReleaseReservation<Tuple<int, int>>(ConstructJoinNewWithNMessages(1))); Assert.True(ISourceBlockTestHelper.TestConsumeMessage <Tuple <int, int> >(ConstructJoinNewWithNMessages(1))); Assert.True(ISourceBlockTestHelper.TestTryReceiveWithFilter <Tuple <int, int> >(ConstructJoinNewWithNMessages(1), 1)); Assert.True(ISourceBlockTestHelper.TestTryReceiveAll <Tuple <int, int> >(ConstructJoinNewWithNMessages(1), 1)); Assert.True(TestJoinMaxNumberOfGroups(greedy: true, sync: true)); Assert.True(TestJoinMaxNumberOfGroups(greedy: true, sync: false)); // {non-greedy sync} is intentioanlly skipped because it is not supported by the block Assert.True(TestJoinMaxNumberOfGroups(greedy: false, sync: false)); }
public void RunTransformBlockTests() { Assert.True(IDataflowBlockTestHelper.TestToString(nameFormat => nameFormat != null ? new TransformBlock <int, int>(x => x, new ExecutionDataflowBlockOptions() { NameFormat = nameFormat }) : new TransformBlock <int, int>(x => x))); Assert.True(ISourceBlockTestHelper.TestLinkTo <string>(ConstructTransformWithNMessages(2), 1)); Assert.True(ISourceBlockTestHelper.TestReserveMessageAndReleaseReservation <string>(ConstructTransformWithNMessages(1))); Assert.True(ISourceBlockTestHelper.TestConsumeMessage <string>(ConstructTransformWithNMessages(1))); Assert.True(ISourceBlockTestHelper.TestTryReceiveWithFilter <string>(ConstructTransformWithNMessages(1), 1)); Assert.True(ISourceBlockTestHelper.TestTryReceiveAll <string>(ConstructTransformWithNMessages(1), 1)); Assert.True(ISourceBlockTestHelper.TestTargetOrder <int>(new TransformBlock <int, int>(x => x), 2)); Assert.True(ITargetBlockTestHelper.TestOfferMessage <int>(new TransformBlock <int, string>(i => i.ToString()))); Assert.True(ITargetBlockTestHelper.TestPost <int>(new TransformBlock <int, string>(i => i.ToString()))); Assert.True(ITargetBlockTestHelper.TestComplete <int>(new TransformBlock <int, string>(i => i.ToString()))); Assert.True(ITargetBlockTestHelper.TestCompletionTask <int>(new TransformBlock <int, string>(i => i.ToString()))); Assert.True(ITargetBlockTestHelper.TestNonGreedyPost(new TransformBlock <int, int>(x => { Task.Delay(5).Wait(); return(x); }, new ExecutionDataflowBlockOptions { BoundedCapacity = 1 }))); Assert.True(TestQuickStop(testThrow: false)); Assert.True(TestQuickStop(testThrow: true)); }