diff --git a/test/Microsoft.AspNetCore.ResponseCaching.Tests/ResponseCachingMiddlewareTests.cs b/test/Microsoft.AspNetCore.ResponseCaching.Tests/ResponseCachingMiddlewareTests.cs index 831e9ea67e..2fb9849993 100644 --- a/test/Microsoft.AspNetCore.ResponseCaching.Tests/ResponseCachingMiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.ResponseCaching.Tests/ResponseCachingMiddlewareTests.cs @@ -632,22 +632,18 @@ namespace Microsoft.AspNetCore.ResponseCaching.Tests [Fact] public async Task FinalizeCacheHeadersAsync_AddsDate_IfNoneSpecified() { - var clock = new TestClock - { - UtcNow = DateTimeOffset.UtcNow - }; + var utcNow = DateTimeOffset.UtcNow; var sink = new TestSink(); - var middleware = TestUtils.CreateTestMiddleware(testSink: sink, options: new ResponseCachingOptions - { - SystemClock = clock - }); + var middleware = TestUtils.CreateTestMiddleware(testSink: sink); var context = TestUtils.CreateTestContext(); + // ResponseTime is the actual value that's used to set the Date header in FinalizeCacheHeadersAsync + context.ResponseTime = utcNow; Assert.True(StringValues.IsNullOrEmpty(context.HttpContext.Response.Headers[HeaderNames.Date])); await middleware.FinalizeCacheHeadersAsync(context); - Assert.Equal(HeaderUtilities.FormatDate(clock.UtcNow), context.HttpContext.Response.Headers[HeaderNames.Date]); + Assert.Equal(HeaderUtilities.FormatDate(utcNow), context.HttpContext.Response.Headers[HeaderNames.Date]); Assert.Empty(sink.Writes); }