diff --git a/test/Microsoft.AspNetCore.ResponseCaching.Tests/ResponseCachingTests.cs b/test/Microsoft.AspNetCore.ResponseCaching.Tests/ResponseCachingTests.cs index 6defe0e..400e5af 100644 --- a/test/Microsoft.AspNetCore.ResponseCaching.Tests/ResponseCachingTests.cs +++ b/test/Microsoft.AspNetCore.ResponseCaching.Tests/ResponseCachingTests.cs @@ -689,15 +689,7 @@ public async void ServesCachedContent_IfIfModifiedSince_NotSatisfied() client.DefaultRequestHeaders.IfUnmodifiedSince = DateTimeOffset.MinValue; var subsequentResponse = await client.GetAsync(""); - initialResponse.EnsureSuccessStatusCode(); - subsequentResponse.EnsureSuccessStatusCode(); - - foreach (var header in initialResponse.Headers) - { - Assert.Equal(initialResponse.Headers.GetValues(header.Key), subsequentResponse.Headers.GetValues(header.Key)); - } - Assert.True(subsequentResponse.Headers.Contains(HeaderNames.Age)); - Assert.Equal(await initialResponse.Content.ReadAsStringAsync(), await subsequentResponse.Content.ReadAsStringAsync()); + await AssertResponseCachedAsync(initialResponse, subsequentResponse); } } @@ -756,15 +748,7 @@ public async void ServesCachedContent_IfIfNoneMatch_NotSatisfied() client.DefaultRequestHeaders.IfNoneMatch.Add(new System.Net.Http.Headers.EntityTagHeaderValue("\"E2\"")); var subsequentResponse = await client.GetAsync(""); - initialResponse.EnsureSuccessStatusCode(); - subsequentResponse.EnsureSuccessStatusCode(); - - foreach (var header in initialResponse.Headers) - { - Assert.Equal(initialResponse.Headers.GetValues(header.Key), subsequentResponse.Headers.GetValues(header.Key)); - } - Assert.True(subsequentResponse.Headers.Contains(HeaderNames.Age)); - Assert.Equal(await initialResponse.Content.ReadAsStringAsync(), await subsequentResponse.Content.ReadAsStringAsync()); + await AssertResponseCachedAsync(initialResponse, subsequentResponse); } }