Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/aspnetcore.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/Middleware/OutputCaching/test/OutputCacheAttributeTests.cs')
-rw-r--r--src/Middleware/OutputCaching/test/OutputCacheAttributeTests.cs16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/Middleware/OutputCaching/test/OutputCacheAttributeTests.cs b/src/Middleware/OutputCaching/test/OutputCacheAttributeTests.cs
index cd43d2d58a..26c4c5bd49 100644
--- a/src/Middleware/OutputCaching/test/OutputCacheAttributeTests.cs
+++ b/src/Middleware/OutputCaching/test/OutputCacheAttributeTests.cs
@@ -48,7 +48,7 @@ public class OutputCacheAttributeTests
var options = new OutputCacheOptions();
options.AddPolicy("MyPolicy", b => b.Expire(TimeSpan.FromSeconds(42)));
- var context = TestUtils.CreateTestContext(options: options);
+ var context = TestUtils.CreateUninitializedContext(options: options);
var attribute = OutputCacheMethods.GetAttribute(nameof(OutputCacheMethods.PolicyName));
await attribute.BuildPolicy().CacheRequestAsync(context, cancellation: default);
@@ -58,6 +58,20 @@ public class OutputCacheAttributeTests
}
[Fact]
+ public async Task Attribute_NamedPolicyDoesNotInjectDefaultPolicy()
+ {
+ var options = new OutputCacheOptions();
+ options.AddPolicy("MyPolicy", b => b.With(x => false).Cache());
+
+ var context = TestUtils.CreateUninitializedContext(options: options);
+
+ var attribute = OutputCacheMethods.GetAttribute(nameof(OutputCacheMethods.PolicyName));
+ await attribute.BuildPolicy().CacheRequestAsync(context, cancellation: default);
+
+ Assert.False(context.EnableOutputCaching);
+ }
+
+ [Fact]
public async Task Attribute_CreatesVaryByHeaderPolicy()
{
var context = TestUtils.CreateUninitializedContext();