Skip to content

Commit 13d9f94

Browse files
committed
Fix build
1 parent be30724 commit 13d9f94

File tree

4 files changed

+17
-22
lines changed

4 files changed

+17
-22
lines changed

src/Hosting/Hosting/test/Microsoft.AspNetCore.Hosting.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<Compile Include="$(SharedSourceRoot)EventSource.Testing\TestCounterListener.cs" />
1212
<Compile Include="$(SharedSourceRoot)SyncPoint\SyncPoint.cs" />
1313
<Compile Include="$(SharedSourceRoot)Metrics\TestMeterFactory.cs" LinkBase="shared" />
14+
<Compile Include="$(SharedSourceRoot)AsyncEnumerableExtensions.cs" LinkBase="shared" />
1415
<Content Include="testroot\**\*" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
1516
<Content Include="Microsoft.AspNetCore.Hosting.StaticWebAssets.xml" CopyToOutputDirectory="PreserveNewest" />
1617
</ItemGroup>

src/Middleware/ConcurrencyLimiter/test/ConcurrencyLimiterEventSourceTests.cs

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Diagnostics.Tracing;
66
using Microsoft.AspNetCore.Internal;
77
using Microsoft.AspNetCore.InternalTesting;
8+
using Microsoft.Extensions.Logging;
89

910
namespace Microsoft.AspNetCore.ConcurrencyLimiter.Tests;
1011

@@ -55,7 +56,7 @@ public async Task TracksQueueLength()
5556

5657
using var timeoutTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
5758

58-
var lengthValues = eventListener.GetCounterValues("queue-length", timeoutTokenSource.Token).GetAsyncEnumerator();
59+
var lengthValues = eventListener.GetCounterValues("queue-length", timeoutTokenSource.Token);
5960

6061
eventListener.EnableEvents(eventSource, EventLevel.Informational, EventKeywords.None,
6162
new Dictionary<string, string>
@@ -66,20 +67,20 @@ public async Task TracksQueueLength()
6667
// Act
6768
eventSource.RequestRejected();
6869

69-
Assert.True(await UntilValueMatches(lengthValues, 0));
70+
await WaitForCounterValue(lengthValues, expectedValue: 0, Logger);
7071
using (eventSource.QueueTimer())
7172
{
72-
Assert.True(await UntilValueMatches(lengthValues, 1));
73+
await WaitForCounterValue(lengthValues, expectedValue: 1, Logger);
7374

7475
using (eventSource.QueueTimer())
7576
{
76-
Assert.True(await UntilValueMatches(lengthValues, 2));
77+
await WaitForCounterValue(lengthValues, expectedValue: 2, Logger);
7778
}
7879

79-
Assert.True(await UntilValueMatches(lengthValues, 1));
80+
await WaitForCounterValue(lengthValues, expectedValue: 1, Logger);
8081
}
8182

82-
Assert.True(await UntilValueMatches(lengthValues, 0));
83+
await WaitForCounterValue(lengthValues, expectedValue: 0, Logger);
8384
}
8485

8586
[Fact]
@@ -96,7 +97,7 @@ public async Task TracksDurationSpentInQueue()
9697

9798
using var timeoutTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5));
9899

99-
var durationValues = eventListener.GetCounterValues("queue-duration", timeoutTokenSource.Token).GetAsyncEnumerator();
100+
var durationValues = eventListener.GetCounterValues("queue-duration", timeoutTokenSource.Token);
100101

101102
eventListener.EnableEvents(eventSource, EventLevel.Informational, EventKeywords.None,
102103
new Dictionary<string, string>
@@ -105,17 +106,17 @@ public async Task TracksDurationSpentInQueue()
105106
});
106107

107108
// Act
108-
Assert.True(await UntilValueMatches(durationValues, 0));
109+
await WaitForCounterValue(durationValues, expectedValue: 0, Logger);
109110

110111
using (eventSource.QueueTimer())
111112
{
112-
Assert.True(await UntilValueMatches(durationValues, 0));
113+
await WaitForCounterValue(durationValues, expectedValue: 0, Logger);
113114
}
114115

115116
// check that something (anything!) has been written
116-
while (await durationValues.MoveNextAsync())
117+
while (await durationValues.Values.MoveNextAsync())
117118
{
118-
if (durationValues.Current > 0)
119+
if (durationValues.Values.Current > 0)
119120
{
120121
return;
121122
}
@@ -124,17 +125,9 @@ public async Task TracksDurationSpentInQueue()
124125
throw new TimeoutException();
125126
}
126127

127-
private async Task<bool> UntilValueMatches(IAsyncEnumerator<double> enumerator, int value)
128+
private static async Task WaitForCounterValue(CounterValues values, double expectedValue, ILogger logger)
128129
{
129-
while (await enumerator.MoveNextAsync())
130-
{
131-
if (enumerator.Current == value)
132-
{
133-
return true;
134-
}
135-
}
136-
137-
return false;
130+
await values.Values.WaitForValueAsync(expectedValue, values.CounterName, logger);
138131
}
139132

140133
private static ConcurrencyLimiterEventSource GetConcurrencyLimiterEventSource()

src/Middleware/ConcurrencyLimiter/test/Microsoft.AspNetCore.ConcurrencyLimiter.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<ItemGroup>
88
<Compile Include="$(SharedSourceRoot)EventSource.Testing\TestCounterListener.cs" />
99
<Compile Include="$(SharedSourceRoot)EventSource.Testing\TestEventListener.cs" />
10+
<Compile Include="$(SharedSourceRoot)AsyncEnumerableExtensions.cs" LinkBase="shared" />
1011
</ItemGroup>
1112

1213
<ItemGroup>

src/Hosting/Hosting/test/Internal/AsyncEnumerableExtensions.cs renamed to src/Shared/AsyncEnumerableExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Numerics;
55
using Microsoft.Extensions.Logging;
66

7-
namespace System.Collections.Generic;
7+
namespace Microsoft.AspNetCore.InternalTesting;
88

99
internal static class AsyncEnumerableExtensions
1010
{

0 commit comments

Comments
 (0)