Beispiel #1
0
        public void ProcessRequest_Should_Write_Correct_Xml_For_Regular_SiteMap()
        {
            _httpContext.HttpRequest.ExpectGet(r => r.Path).Returns("sitemap.axd");
            _httpContext.HttpResponse.Expect(r => r.Write(It.IsAny <string>())).Verifiable();

            _handler.ProcessRequest(_httpContext.Object);
        }
Beispiel #2
0
        private void Process(Mock <Stream> outputStream)
        {
            TestHelper.RegisterDummyRoutes();

            _siteMaps.Register <XmlSiteMap>("x", siteMap =>
            {
                SiteMapNodeBuilder rootNode = siteMap.RootNode;

                rootNode.Title("Home")
                .Route("Default")
                .LastModifiedAt(DateTime.UtcNow)
                .ChangeFrequency(SiteMapChangeFrequency.Hourly)
                .UpdatePriority(SiteMapUpdatePriority.Critical)
                .ChildNodes(node =>
                {
                    node.Add()
                    .Title("Products")
                    .Route("ProductList")
                    .ChildNodes(childNode =>
                    {
                        childNode.Add()
                        .Title("Product1")
                        .Action("Detail", "Product", new { id = 1 });

                        childNode.Add()
                        .Title("Product2")
                        .Action("Detail", "Product", new { id = 2 });
                    }
                                );

                    node.Add()
                    .Title("Faq")
                    .Url("~Faq");
                });
            }
                                            );

            _httpContext.Setup(context => context.Response.OutputStream).Returns(outputStream.Object);

            _compressor.Setup(compressor => compressor.Compress(_httpContext.Object)).Verifiable();
            _cacher.Setup(cacher => cacher.Cache(_httpContext.Object, It.IsAny <TimeSpan>())).Verifiable();
            _urlGenerator.Setup(generater => generater.Generate(It.IsAny <RequestContext>(), It.IsAny <INavigatable>())).Returns("http://localhost/Griffin/Home").Verifiable();

            outputStream.SetupGet(stream => stream.CanRead).Returns(true);
            outputStream.SetupGet(stream => stream.CanWrite).Returns(true);
            outputStream.SetupGet(stream => stream.CanSeek).Returns(true);

            outputStream.Setup(stream => stream.Write(It.IsAny <byte[]>(), It.IsAny <int>(), It.IsAny <int>())).Verifiable();

            _httpContext.Object.Request.QueryString.Add("name", "x");

            _handler.ProcessRequest(_httpContext.Object);
        }