/// <summary>
 /// Initializes a new instance of the <see cref="FakeHttpCachePolicy"/> class.
 /// </summary>
 public FakeHttpCachePolicy()
 {
     this.cacheExtensions = new List<string>();
     this.validationCallbacks = new List<Tuple<HttpCacheValidateHandler, object>>();
     this.varyByContentEncodings = new HttpCacheVaryByContentEncodings();
     this.varyByHeaders = new HttpCacheVaryByHeaders();
     this.varyByParams = new HttpCacheVaryByParams();
 }
        public void OutputCacheSetsVaryByValues()
        {
            // Arrange
            var timestamp = new DateTime(2011, 1, 1, 0, 0, 0);
            var context = new Mock<HttpContextBase>();
            context.SetupGet(c => c.Timestamp).Returns(timestamp);
            var response = new Mock<HttpResponseBase>().Object;

            var varyByParams = new HttpCacheVaryByParams();
            var varyByHeader = new HttpCacheVaryByHeaders();
            var varyByContentEncoding = new HttpCacheVaryByContentEncodings();

            var cache = new Mock<HttpCachePolicyBase>();
            cache.SetupGet(c => c.VaryByParams).Returns(varyByParams);
            cache.SetupGet(c => c.VaryByHeaders).Returns(varyByHeader);
            cache.SetupGet(c => c.VaryByContentEncodings).Returns(varyByContentEncoding);

            // Act
            ResponseExtensions.OutputCache(context.Object, cache.Object, 20, false, new[] { "foo" }, new[] { "bar", "bar2" },
                                           new[] { "baz", "baz2" }, HttpCacheability.Public);

            // Assert
            Assert.Equal(varyByParams["foo"], true);
            Assert.Equal(varyByHeader["bar"], true);
            Assert.Equal(varyByHeader["bar2"], true);
            Assert.Equal(varyByContentEncoding["baz"], true);
            Assert.Equal(varyByContentEncoding["baz2"], true);
        }
 internal HttpCachePolicy() {
     _varyByContentEncodings = new HttpCacheVaryByContentEncodings();
     _varyByHeaders = new HttpCacheVaryByHeaders();
     _varyByParams = new HttpCacheVaryByParams();
     Reset();
 }
    internal void SetVaryByParamsCollectionFromString(string varyByParams) {

        Debug.Assert(_varyByParamsCollection == null);

        if (varyByParams == null)
            return;

        string[] varyByParamsStrings = varyByParams.Split(varySeparator);
        _varyByParamsCollection = new HttpCacheVaryByParams();
        _varyByParamsCollection.ResetFromParams(varyByParamsStrings);
    }
 internal void SetVaryByParamsCollectionFromString(string varyByParams)
 {
     if (varyByParams != null)
     {
         string[] parameters = varyByParams.Split(new char[] { ';' });
         this._varyByParamsCollection = new HttpCacheVaryByParams();
         this._varyByParamsCollection.ResetFromParams(parameters);
     }
 }