Exemple #1
0
        public void BuildHttpRequestNull()
        {
            var urlBaseBuilder     = new Mock <IUrlBaseBuilder>(MockBehavior.Strict).Object;
            var pageLinksFormatter = new Mock <IPageLinksFormatter>(MockBehavior.Strict).Object;
            var uut = new PageLinksBuilder(urlBaseBuilder, pageLinksFormatter);

            Assert.Throws <ArgumentNullException>
            (
                () => uut.Build(new Page <Uom>(), null)
            );
        }
Exemple #2
0
        public void BuildPageNull()
        {
            var httpRequest        = new DefaultHttpRequest(new DefaultHttpContext());
            var urlBaseBuilder     = new Mock <IUrlBaseBuilder>(MockBehavior.Strict).Object;
            var pageLinksFormatter = new Mock <IPageLinksFormatter>(MockBehavior.Strict).Object;
            var uut = new PageLinksBuilder(urlBaseBuilder, pageLinksFormatter);

            Assert.Throws <ArgumentNullException>
            (
                () => uut.Build <Uom>(null, httpRequest)
            );
        }
Exemple #3
0
        public void BuildSucceeds()
        {
            var page           = new Page <Uom>();
            var httpRequest    = new DefaultHttpRequest(new DefaultHttpContext());
            var urlBases       = new UrlBases("http://localhost/acid/base", "http://localhost");
            var urlBaseBuilder = new Mock <IUrlBaseBuilder>(MockBehavior.Strict);

            urlBaseBuilder.Setup(u => u.Build(httpRequest)).Returns(urlBases);
            var expectedLinks      = "theLinks";
            var pageLinksFormatter = new Mock <IPageLinksFormatter>(MockBehavior.Strict);

            pageLinksFormatter.Setup(f => f.GetLinks(urlBases.ReadUrl, page)).Returns(expectedLinks);
            var uut         = new PageLinksBuilder(urlBaseBuilder.Object, pageLinksFormatter.Object);
            var actualLinks = uut.Build(page, httpRequest);

            Assert.AreEqual(expectedLinks, actualLinks);
        }