Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@ public class ThrottlingCacheTests
private readonly MsalServiceException _ex2 = new MsalServiceException("code2", "msg2");

[TestMethod]
public async Task GetRemovesExpired_Async()
public void GetRemovesExpired()
{
// Arrange
ThrottlingCache cache = new ThrottlingCache();

cache.AddAndCleanup("k1", new ThrottlingCacheEntry(_ex1, TimeSpan.FromMilliseconds(1)), _logger); // expired
cache.AddAndCleanup("k1", new ThrottlingCacheEntry(_ex1, TimeSpan.FromMilliseconds(-10000)), _logger); // expired
cache.AddAndCleanup("k2", new ThrottlingCacheEntry(_ex2, TimeSpan.FromMilliseconds(10000)), _logger);

// Act
await Task.Delay(1).ConfigureAwait(false);
bool isFound1 = cache.TryGetOrRemoveExpired("k1", _logger, out MsalServiceException foundEx1);
bool isFound2 = cache.TryGetOrRemoveExpired("k2", _logger, out MsalServiceException foundEx2);

Expand All @@ -39,16 +38,15 @@ public async Task GetRemovesExpired_Async()
}

[TestMethod]
public async Task TestCleanup_Async()
public void TestCleanup()
{
// Arrange
ThrottlingCache cache = new ThrottlingCache(50);

cache.AddAndCleanup("k1", new ThrottlingCacheEntry(_ex1, TimeSpan.FromMilliseconds(1)), _logger); // expired
cache.AddAndCleanup("k1", new ThrottlingCacheEntry(_ex1, TimeSpan.FromMilliseconds(-10000)), _logger); // expired
cache.AddAndCleanup("k2", new ThrottlingCacheEntry(_ex2, TimeSpan.FromMilliseconds(10000)), _logger);

// Act - should trigger a cleanup
await Task.Delay(50).ConfigureAwait(false);
cache.AddAndCleanup("k3", new ThrottlingCacheEntry(_ex2, TimeSpan.FromMilliseconds(1000)), _logger);

// Assert
Expand Down