public void CreatesCorrectPolicyWithAttributesAndParameters() { var attributes = new CacheLookupAttributesBuilder() .VaryByDeveloper(true) .VaryByDeveloperGroups(false) .DownstreamCachingType(DownstreamCachingType.Public) .AllowPrivateResponseCaching(true) .Create(); var basePolicy = (SectionPolicy) new CacheLookupSectionBuilder(attributes) .VaryByHeader(headerTenant) .VaryByHeader(headerApplication) .VaryByQueryParameter(queryParam) .Create(); var xml = basePolicy.GetXml().ToString(); xml.Should().Be( $@"<cache-lookup vary-by-developer=""true"" vary-by-developer-groups=""false"" downstream-caching-type=""public"" allow-private-response-caching=""true""> <vary-by-header>{headerTenant}</vary-by-header> <vary-by-header>{headerApplication}</vary-by-header> <vary-by-query-parameter>{queryParam}</vary-by-query-parameter> </cache-lookup>"); }
public void CreatesCorrectPolicy() { var attributes = new CacheLookupAttributesBuilder().Create(); var basePolicy = (SectionPolicy) new CacheLookupSectionBuilder(attributes).Create(); var xml = basePolicy.GetXml().ToString(); xml.Should().Be("<cache-lookup />"); }
/// <inheritdoc /> public IInboundSectionPolicyBuilder CacheLookup(Func <ICacheLookupAttributesBuilder, IDictionary <string, string> > cachingAttributesBuilder) { var attributesBuilder = new CacheLookupAttributesBuilder(); var attributes = cachingAttributesBuilder.Invoke(attributesBuilder); var policy = new CacheLookupPolicy(attributes); return(AddPolicyDefinition(policy)); }
/// <inheritdoc /> public IInboundSectionPolicyBuilder CacheLookup(Func <ICacheLookupAttributesBuilder, IDictionary <string, string> > cachingAttributesBuilder, Func <ICacheLookupSectionBuilder, ISectionPolicy> cachingSectionPolicyBuilder = null) { if (cachingSectionPolicyBuilder == null) { cachingSectionPolicyBuilder = new Func <ICacheLookupSectionBuilder, ISectionPolicy>(x => x.Create()); } var attributesBuilder = new CacheLookupAttributesBuilder(); var attributes = cachingAttributesBuilder.Invoke(attributesBuilder); var policyBuilder = new CacheLookupSectionBuilder(attributes); return(AddPolicyDefinition(cachingSectionPolicyBuilder.Invoke(policyBuilder))); }
public void CreatesCorrectPolicyWithAttributes() { var attributes = new CacheLookupAttributesBuilder() .VaryByDeveloper(true) .VaryByDeveloperGroups(false) .DownstreamCachingType(DownstreamCachingType.Public) .AllowPrivateResponseCaching(true) .Create(); var basePolicy = (SectionPolicy) new CacheLookupSectionBuilder(attributes).Create(); var xml = basePolicy.GetXml().ToString(); xml.Should().Be( $"<cache-lookup vary-by-developer=\"true\" vary-by-developer-groups=\"false\" downstream-caching-type=\"public\" allow-private-response-caching=\"true\" />"); }