Ejemplo n.º 1
0
        public void ProcessRequest_Should_Write_Xml()
        {
            string xml;

            cache.Setup(c => c.TryGet(It.IsAny <string>(), out xml)).Returns(false);

            var handler = new XrdsHandler
            {
                Settings            = settings.Object,
                CacheDurationInDays = 365,
                Compress            = true,
                GenerateETag        = true
            };

            _httpContext.HttpResponse.Setup(r => r.Write(It.IsAny <string>())).Verifiable();

            handler.ProcessRequest(_httpContext.Object);

            _httpContext.Verify();
        }
Ejemplo n.º 2
0
        public void ProcessRequest_Should_Cache_Content()
        {
            string xml;

            cache.Setup(c => c.TryGet(It.IsAny <string>(), out xml)).Returns(false);
            cache.Setup(c => c.Contains(It.IsAny <string>())).Returns(false);
            cache.Setup(c => c.Set(It.IsAny <string>(), It.IsAny <HandlerCacheItem>(), It.IsAny <DateTime>())).Verifiable();

            var handler = new XrdsHandler
            {
                Settings            = settings.Object,
                CacheDurationInDays = 365,
                Compress            = true,
                GenerateETag        = true
            };

            handler.ProcessRequest(_httpContext.Object);

            cache.Verify();
        }
Ejemplo n.º 3
0
        public void ProcessRequest_Should_Not_Write_Xml_When_Xml_Is_Not_Modified()
        {
            string xml;

            cache.Expect(c => c.TryGet(It.IsAny <string>(), out xml)).Returns(false);

            var handler = new XrdsHandler
            {
                Settings            = settings.Object,
                CacheDurationInDays = 365,
                Compress            = true,
                GenerateETag        = true
            };

            _httpContext.HttpRequest.ExpectGet(r => r.Headers).Returns(new NameValueCollection {
                { "If-None-Match", "cPL22YznvwACntJKLjS+2w==" }
            });
            _httpContext.HttpResponse.Expect(r => r.Write(It.IsAny <string>())).Never();

            handler.ProcessRequest(_httpContext.Object);

            _httpContext.Verify();
        }