Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public void Should_be_able_to_register_site_map()
        {
            _sitemaps.Register <XmlSiteMap>("foo", sitmap => { });

            Assert.True(_sitemaps.ContainsKey("foo"));
        }