public void Test(string url, string expected)
        {
            var mockProductProvider = new Mock<IProductProvider>();

            mockProductProvider.Setup(x => x.Get(It.IsAny<int>()))
                .Returns(new Product
                {
                    Id = 2,
                    Ref = "britax-b-agile-3-wheel-pushchair",
                    Brand = new Brand
                    {
                        Name = "Britax"
                    }
                });

            var mockProductUrlIdExtractor = new Mock<IProductUrlIdExtractor>();

            mockProductUrlIdExtractor.Setup(x => x.Extract(It.IsAny<string>()))
                .Returns(1);

            var sut = new ProductUrlConverter(mockProductProvider.Object, mockProductUrlIdExtractor.Object, new ProductUrlBuilder());

            var actual = sut.Convert(url);
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 2
0
        public void Configuration(IAppBuilder app)
        {
            var productUrlConverter = new ProductUrlConverter(
                new ProductProvider(),
                new ProductUrlIdExtractor(),
                new ProductUrlBuilder());

            app.UseCanonicalUrls(x => x
                .MapUrl("/home/", "/")
                .MapUrl("/home/index/", "/")
                .MapUrl("/default/", "/")
                .MapUrl("/index/", "/")
                .WithTrailingSlash()
                .UseLowerCase()
                .UsingUrlConverter(productUrlConverter));

            ConfigureAuth(app);
        }