From d5fa3093f388633aeef41705ffd01659a36b440a Mon Sep 17 00:00:00 2001 From: oca-agent <277152249+oca-agent@users.noreply.github.com> Date: Thu, 14 May 2026 21:11:25 -0400 Subject: [PATCH] test: address xUnit1051 warnings in InMemoryCacheServiceTest --- .../Services/Caching/InMemoryCacheServiceTest.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/smoc.Tests/Services/Caching/InMemoryCacheServiceTest.cs b/smoc.Tests/Services/Caching/InMemoryCacheServiceTest.cs index 10d636e..9f626a9 100644 --- a/smoc.Tests/Services/Caching/InMemoryCacheServiceTest.cs +++ b/smoc.Tests/Services/Caching/InMemoryCacheServiceTest.cs @@ -64,7 +64,7 @@ public async Task Evict_LRU_RespectsMaxElements() { // Access key1 to make it recently used, key2 will be least recently used (if we consider insertion order as usage, but let's be explicit) // Wait a bit to ensure timestamps are different if resolution is low, or just rely on order. - await Task.Delay(10); + await Task.Delay(10, TestContext.Current.CancellationToken); await service.GetOrAddAsync(key1, _ => Task.FromResult(new MemoryStream()), TestContext.Current.CancellationToken); await service.Evict(TestContext.Current.CancellationToken); @@ -132,9 +132,9 @@ public async Task Evict_LRU_RespectsMaxSizeBytes() { string key3 = "key3"; await service.GetOrAddAsync(key1, _ => Task.FromResult(new MemoryStream(Encoding.UTF8.GetBytes("a"))), TestContext.Current.CancellationToken); - await Task.Delay(10); + await Task.Delay(10, TestContext.Current.CancellationToken); await service.GetOrAddAsync(key2, _ => Task.FromResult(new MemoryStream(Encoding.UTF8.GetBytes("b"))), TestContext.Current.CancellationToken); - await Task.Delay(10); + await Task.Delay(10, TestContext.Current.CancellationToken); await service.GetOrAddAsync(key3, _ => Task.FromResult(new MemoryStream(Encoding.UTF8.GetBytes("c"))), TestContext.Current.CancellationToken); await service.Evict(TestContext.Current.CancellationToken); @@ -182,7 +182,7 @@ public async Task GetOrAddAsync_IsThreadSafe_SerializesFactoryExecution() { }, TestContext.Current.CancellationToken); // Give Task 2 a moment to potentially run (it shouldn't) - await Task.Delay(50); + await Task.Delay(50, TestContext.Current.CancellationToken); Assert.False(task2FactoryCalled, "Task 2 should be blocked while Task 1 holds the lock."); Assert.False(task2.IsCompleted, "Task 2 should not complete yet."); @@ -213,7 +213,7 @@ public async Task Evict_IsThreadSafe_WaitsForGetOrAdd() { // Task 2: Evict (should be blocked) var evictTask = service.Evict(TestContext.Current.CancellationToken); - await Task.Delay(50); + await Task.Delay(50, TestContext.Current.CancellationToken); Assert.False(evictTask.IsCompleted, "Evict should be blocked while Task 1 holds the lock."); // Release Task 1