{
var firstRequestReceived = new SemaphoreSlim(0, 1);
var secondRequestSent = new SemaphoreSlim(0, 1);
+ var firstRequestFinished = new SemaphoreSlim(0, 1);
await GetFactoryForVersion(version).CreateClientAndServerAsync(
async uri =>
Task secondRequest = client.GetStringAsync(uri);
secondRequestSent.Release();
- await new[] { firstRequest, secondRequest }.WhenAllOrAnyFailed();
+ // We are asserting that ActivityIds between Start/Stop pairs match below
+ // We wait for the first request to finish to ensure that RequestStop events
+ // are logged in the same order as RequestStarts
+ await firstRequest;
+ firstRequestFinished.Release();
+
+ await secondRequest;
},
async server =>
{
await connection.SendResponseAsync();
// Second request
+ Assert.True(await firstRequestFinished.WaitAsync(TimeSpan.FromSeconds(10)));
await connection.ReadRequestDataAsync(readBody: false);
await connection.SendResponseAsync();
};