As it turned out, that no solution exists which matches my needs, I used the remaining days of the year to write a concurrency test helper. This is from the unit tests and it shows three parallel code blocks that are executed, synchronized and analyzed using the test helper class:
[Test]
public void SetWaitMultipleEventsTest()
{
CTestHelper.Run(
c =>
{
Thread.Sleep(1000);
CTestHelper.AddSequenceStep("s1", "Provide1");
CTestHelper.SetEvent("e1");
},
c =>
{
Thread.Sleep(1000);
CTestHelper.AddSequenceStep("s2", "Provide2");
CTestHelper.SetEvent("e2");
},
c =>
{
CTestHelper.WaitAllEvents(new[] { "e1", "e2" });
CTestHelper.AddSequenceStep("s1", "Consume1");
CTestHelper.AddSequenceStep("s2", "Consume2");
},
TimeSpan.FromSeconds(10));
Expect(CTestHelper.GetSequence("s1"), Is.EquivalentTo(new[] { "Provide1", "Consume1" }));
Expect(CTestHelper.GetSequence("s2"), Is.EquivalentTo(new[] { "Provide2", "Consume2" }));
}
The CTestHelper.Run() method runs the provided code blocks (Actions) in parallel and waits until they are finished or a timeout has occurred. Synchronization mechanisms,... are provided too. Samples will follow soon.
Resources (so far):
Crawler-Lib Concurrency Testing Helper Home
Crawler-Lib Concurrency Testing Helper NuGet Package