Exemplo n.º 1
0
        public string BuildHtml(string bodyHtml)
        {
            string pageTemplate = _fileLocator.ReadTextFile("Tarantino.Core", PageTemplate);
            string cssHtml      = _fileLocator.ReadTextFile("Tarantino.Core", StylesheetTemplate);
            string menuHtml     = _menuView.BuildHtml();

            _replacer.Text = pageTemplate;

            _replacer.Replace("CSS", cssHtml);
            _replacer.Replace("MENU", menuHtml);
            _replacer.Replace("BODY", bodyHtml);

            return(_replacer.Text);
        }
Exemplo n.º 2
0
        public void Correctly_renders_page_view()
        {
            string cssText = "css stuff";

            MockRepository       mocks       = new MockRepository();
            IResourceFileLocator fileLocator = mocks.CreateMock <IResourceFileLocator>();
            ITokenReplacer       replacer    = mocks.CreateMock <ITokenReplacer>();
            IMenuView            menuView    = mocks.CreateMock <IMenuView>();

            using (mocks.Record())
            {
                string htmlTemplate = "||CSS|| ||MENU|| ||BODY||";
                Expect.Call(fileLocator.ReadTextFile("Tarantino.Core", PageView.PageTemplate)).Return(htmlTemplate);

                replacer.Text = htmlTemplate;

                Expect.Call(fileLocator.ReadTextFile("Tarantino.Core", PageView.StylesheetTemplate)).Return(cssText);

                replacer.Replace("CSS", cssText);

                Expect.Call(menuView.BuildHtml()).Return("menu stuff");
                replacer.Replace("MENU", "menu stuff");

                replacer.Replace("BODY", "body stuff");

                Expect.Call(replacer.Text).Return("page content");
            }

            using (mocks.Playback())
            {
                IPageView pageView = new PageView(fileLocator, menuView, replacer);
                string    html     = pageView.BuildHtml("body stuff");

                Assert.That(html, Is.EqualTo("page content"));
            }
        }