public CachePolicyProviderTests()
 {
     this.response = new HttpResponseMessage();
     this.response.Content = new StringContent("Hello");
     this.policy = new CachePolicy();
     this.provider = new CachePolicyProvider(this.policy);
 }
Esempio n. 2
0
 public CachePolicyProviderTests()
 {
     this.response         = new HttpResponseMessage();
     this.response.Content = new StringContent("Hello");
     this.policy           = new CachePolicy();
     this.provider         = new CachePolicyProvider(this.policy);
 }
        public void SetCachePolicyProvider_Roundtrips()
        {
            // Arrange
            CachePolicyProvider provider = new CachePolicyProvider();
            HttpConfiguration config = new HttpConfiguration();

            // Act
            config.SetCachePolicyProvider(provider);
            ICachePolicyProvider actual = config.GetCachePolicyProvider();

            // Assert
            Assert.Same(provider, actual);
        }
        /// <summary>
        /// Gets the <see cref="Microsoft.Azure.Mobile.Server.Cache.ICachePolicyProvider"/> registered with the current <see cref="System.Web.Http.HttpConfiguration" />.
        /// </summary>
        /// <param name="config">The current <see cref="System.Web.Http.HttpConfiguration"/>.</param>
        /// <returns>The registered instance.</returns>
        public static ICachePolicyProvider GetCachePolicyProvider(this HttpConfiguration config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            ICachePolicyProvider provider = null;
            if (!config.Properties.TryGetValue(CachePolicyProviderKey, out provider))
            {
                provider = new CachePolicyProvider();
                config.Properties[CachePolicyProviderKey] = provider;
            }

            return provider;
        }