Skip to content

Commit e6bc36e

Browse files
committed
Fix SlidingCacheTests
1 parent 7e3b8ed commit e6bc36e

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

test/System.Linq.Dynamic.Core.Tests/Util/Cache/SlidingCacheTests.cs

+11-11
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ public void SlidingCache_CacheOperations()
3434
cache.Count.Should().Be(3, $"Expected 3 items in the cache, only had {cache.Count}");
3535

3636
// Test retrieval
37-
Assert.True(cache.TryGetValue(1, out var value1), "Expected to find the value, but did not");
38-
Assert.True(cache.TryGetValue(2, out var value2), "Expected to find the value, but did not");
39-
Assert.True(cache.TryGetValue(3, out var value3), "Expected to find the value, but did not");
37+
Assert.True(cache.TryGetValue(1, out _), "Expected to find the value, but did not");
38+
Assert.True(cache.TryGetValue(2, out _), "Expected to find the value, but did not");
39+
Assert.True(cache.TryGetValue(3, out _), "Expected to find the value, but did not");
4040

4141
// Test Removal
4242
cache.Remove(1);
@@ -58,7 +58,7 @@ public void SlidingCache_TestExpire()
5858
cache.AddOrUpdate(1, "one");
5959

6060
// move the time forward
61-
var newDateTime = dateTimeUtilsMock.Object.UtcNow.AddMinutes(11);
61+
var newDateTime = UtcNow.AddMinutes(11);
6262
dateTimeUtilsMock.SetupGet(d => d.UtcNow).Returns(newDateTime);
6363

6464
// Ensure that the element has expired
@@ -79,12 +79,12 @@ public void SlidingCache_TestReturnExpiredItems()
7979
// Act
8080
cache.AddOrUpdate(1, "one");
8181

82-
// move the time forward
83-
var newDateTime = dateTimeUtilsMock.Object.UtcNow.AddMinutes(11);
82+
// move the time forward
83+
var newDateTime = UtcNow.AddMinutes(11);
8484
dateTimeUtilsMock.SetupGet(d => d.UtcNow).Returns(newDateTime);
8585

8686
// Ensure the expired item is returned from the cache
87-
cache.TryGetValue(1, out _).Should().BeTrue($"Expected to return expired item");
87+
cache.TryGetValue(1, out _).Should().BeTrue("Expected to return expired item");
8888
}
8989

9090
[Fact]
@@ -103,10 +103,10 @@ public void SlidingCache_TestAutoExpire()
103103
cache.AddOrUpdate(1, "one");
104104

105105
// Ensure one item is in the cache
106-
cache.Count.Should().Be(1, $"Expected 1 items in the cache, only had {cache.Count}");
106+
cache.Count.Should().Be(1, $"Expected 1 items in the cache, had {cache.Count}");
107107

108108
// move the time forward
109-
var newDateTime = dateTimeUtilsMock.Object.UtcNow.AddMinutes(11);
109+
var newDateTime = UtcNow.AddMinutes(11);
110110
dateTimeUtilsMock.SetupGet(d => d.UtcNow).Returns(newDateTime);
111111

112112
// Trigger the cleanup, asking for non-existing key
@@ -117,7 +117,7 @@ public void SlidingCache_TestAutoExpire()
117117
Threading.Thread.Sleep(10);
118118

119119
// Ensure one item is in the cache
120-
cache.Count.Should().Be(0, $"Expected 0 items in the cache, only had {cache.Count}");
120+
cache.Count.Should().Be(0, $"Expected 0 items in the cache, had {cache.Count}");
121121
}
122122

123123
[Fact]
@@ -150,7 +150,7 @@ public void SlidingCache_TestMinNumberBeforeTests()
150150
cache.Count.Should().Be(1, $"Expected 1 items in the cache, only had {cache.Count}");
151151

152152
// move the time forward
153-
var newDateTime = dateTimeUtilsMock.Object.UtcNow.AddMinutes(11);
153+
var newDateTime = UtcNow.AddMinutes(11);
154154
dateTimeUtilsMock.SetupGet(d => d.UtcNow).Returns(newDateTime);
155155

156156
// Trigger the cleanup, asking for non-existing key

0 commit comments

Comments
 (0)