Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/Aspire.Dashboard.Tests/ChannelExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public async Task GetBatchesAsync_MinReadInterval_WaitForNextRead()
Assert.Equal(["d", "e", "f"], read2.Single());

var elapsed = stopwatch.Elapsed;
Assert.True(elapsed >= minReadInterval, $"Elapsed time {elapsed} should be greater than min read interval {minReadInterval} on read.");
CustomAssert.AssertExceedsMinInterval(elapsed, minReadInterval);

channel.Writer.Complete();
await TaskHelpers.WaitIgnoreCancelAsync(readTask);
Expand Down
15 changes: 15 additions & 0 deletions tests/Aspire.Dashboard.Tests/CustomAssert.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Xunit;

namespace Aspire.Dashboard.Tests;

public static class CustomAssert
{
public static void AssertExceedsMinInterval(TimeSpan duration, TimeSpan minInterval)
{
// Timers are not precise, so we allow for a small margin of error.
Assert.True(duration >= minInterval.Subtract(TimeSpan.FromMilliseconds(20)), $"Elapsed time {duration} should be greater than min interval {minInterval}.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,6 @@ public async Task Subscription_MultipleUpdates_MinExecuteIntervalApplied()
Assert.Equal(2, read2);

var elapsed = stopwatch.Elapsed;
Assert.True(elapsed >= minExecuteInterval, $"Elapsed time {elapsed} should be greater than min execute interval {minExecuteInterval} on read.");
CustomAssert.AssertExceedsMinInterval(elapsed, minExecuteInterval);
}
}