コード例 #1
0
    public async Task VaryByValuePolicy_SingleValueAsync()
    {
        var context = TestUtils.CreateUninitializedContext();
        var value   = "value";

        IOutputCachePolicy policy = new VaryByValuePolicy((context, token) => ValueTask.FromResult(value));

        await policy.CacheRequestAsync(context, default);

        Assert.Equal(value, context.CacheVaryByRules.VaryByPrefix);
    }
コード例 #2
0
    public async Task VaryByValuePolicy_KeyValuePairAsync()
    {
        var context = TestUtils.CreateUninitializedContext();
        var key     = "key";
        var value   = "value";

        IOutputCachePolicy policy = new VaryByValuePolicy((context, token) => ValueTask.FromResult(new KeyValuePair <string, string>(key, value)));

        await policy.CacheRequestAsync(context, default);

        Assert.Contains(new KeyValuePair <string, string>(key, value), context.CacheVaryByRules.VaryByCustom);
    }