Exemplo n.º 1
0
        public void RelativeApplicationPaths()
        {
            mocks.ReplayAll();
            var viewContext = MakeViewContext("relativeapplicationpaths", null);

            factory.RenderView(viewContext);
            mocks.VerifyAll();

            string content = sb.ToString();

            Assert.That(content, Contains.InOrder(
                            "<img src=\"/TestApp/content/images/etc.png\"/>",
                            "<script src=\"/TestApp/content/js/etc.js\"/>",
                            "<p class=\"~/blah.css\"/>"));
        }
Exemplo n.º 2
0
        public void EachAttribute()
        {
            mocks.ReplayAll();
            var viewContext = MakeViewContext("eachattribute", null);

            factory.RenderView(viewContext);
            mocks.VerifyAll();
            string content = sb.ToString();

            Assert.That(content, Contains.InOrder(
                            "<td>Bob</td>",
                            "<td>James</td>",
                            "<td>SpecialName</td>",
                            "<td>Anonymous</td>"));
        }
Exemplo n.º 3
0
        public void ChainingElseIfAttribute()
        {
            mocks.ReplayAll();
            var viewContext = MakeViewContext("elseifattribute", null);

            factory.RenderView(viewContext);
            mocks.VerifyAll();
            string content = sb.ToString();

            Assert.That(content, Contains.InOrder(
                            "<p>Hi Bob!</p>",
                            "<p>Administrator James</p>",
                            "<p>Test user.</p>",
                            "<p>Anonymous user.</p>"));
        }
Exemplo n.º 4
0
        public void PartialInMacroMayUseDefaultElement()
        {
            mocks.ReplayAll();
            var viewContext = MakeViewContext("PartialInMacroMayUseDefaultElement", null);

            factory.RenderView(viewContext);
            mocks.VerifyAll();
            string content = sb.ToString();

            Assert.That(content, Contains.InOrder(
                            "<p>3hello</p>",
                            "<p>2hello.</p>",
                            "<p>1hello..</p>",
                            "<p>0hello...</p>"));
        }
Exemplo n.º 5
0
        public void DefaultValuesStandInForNullViewData()
        {
            mocks.ReplayAll();
            var viewData    = new StubViewData();
            var viewContext = MakeViewContext("DefaultValuesStandInForNullViewData", null, viewData);

            factory.RenderView(viewContext);
            mocks.VerifyAll();
            string content = sb.ToString();

            Assert.IsFalse(content.Contains("default"));

            Assert.That(content, Contains.InOrder("ok1", "ok2"));
            Assert.IsFalse(content.Contains("fail"));
        }
Exemplo n.º 6
0
        public void DefaultValuesDontReplaceGlobals()
        {
            mocks.ReplayAll();

            var viewContext = MakeViewContext("DefaultValuesDontReplaceGlobals", null);

            factory.RenderView(viewContext);
            mocks.VerifyAll();
            string content = sb.ToString();

            Assert.IsFalse(content.Contains("default"));

            Assert.That(content, Contains.InOrder("ok1", "ok2"));
            Assert.IsFalse(content.Contains("fail"));
        }
Exemplo n.º 7
0
        public void ForEachMoreAutoVariable()
        {
            mocks.ReplayAll();
            var viewContext = MakeViewContext("foreach-moreautovariables", null);

            factory.RenderView(viewContext);
            mocks.VerifyAll();

            string content = sb.ToString().Replace(" ", "").Replace("\t", "").Replace("\r\n", "");

            Assert.That(content, Contains.InOrder(
                            "<tr><td>one</td><td>0</td><td>4</td><td>True</td><td>False</td></tr>",
                            "<tr><td>two</td><td>1</td><td>4</td><td>False</td><td>False</td></tr>",
                            "<tr><td>three</td><td>2</td><td>4</td><td>False</td><td>False</td></tr>",
                            "<tr><td>four</td><td>3</td><td>4</td><td>False</td><td>True</td></tr>"));
        }
Exemplo n.º 8
0
        public void PartialFilesCanHaveSpecialElements()
        {
            mocks.ReplayAll();
            var viewContext = MakeViewContext("partialspecialelements", null, new StubViewData {
                { "foo", "alpha" }
            });

            factory.RenderView(viewContext);
            mocks.VerifyAll();

            string content = sb.ToString();

            Assert.That(content, Contains.InOrder(
                            "Hi there, alpha.",
                            "Hi there, alpha."));
        }
Exemplo n.º 9
0
        public void EachAttributeWorksOnSpecialNodes()
        {
            mocks.ReplayAll();
            var viewContext = MakeViewContext("EachAttributeWorksOnSpecialNodes", null);

            factory.RenderView(viewContext);
            mocks.VerifyAll();
            string content = sb.ToString();

            Assert.That(content, Contains.InOrder(
                            "<p>name-0-alpha</p>",
                            "<p>name-1-beta</p>",
                            "<p>name-2-gamma</p>",
                            "<span>one</span>",
                            "<span>two</span>",
                            "<span>three</span>"));
        }
Exemplo n.º 10
0
        public void NullExceptionHandledAutomatically()
        {
            mocks.ReplayAll();
            var viewData    = new StubViewData();
            var viewContext = MakeViewContext("NullExceptionHandledAutomatically", null, viewData);

            factory.RenderView(viewContext);
            mocks.VerifyAll();
            string content = sb.ToString();

            Assert.IsFalse(content.Contains("default"));

            Assert.That(content, Contains.InOrder(
                            "<p>name kaboom *${user.Name}*</p>",
                            "<p>name silently **</p>",
                            "<p>name fixed *fred*</p>"));
        }
Exemplo n.º 11
0
        public void RenderlPartialWithDotInName()
        {
            mocks.ReplayAll();
            var viewContext = MakeViewContext("render-dotted-partial", null);

            factory.RenderView(viewContext);
            mocks.VerifyAll();
            string content = sb.ToString();

            Assert.That(content, Contains.InOrder(
                            "<p>",
                            "this.is.some.text:",
                            "test456",
                            "</p>"
                            ));

            Assert.IsFalse(content.Contains("<PartialWith.Dot"));
        }
Exemplo n.º 12
0
        public void Ignore()
        {
            mocks.ReplayAll();
            var viewContext = MakeViewContext("ignore", null);

            factory.RenderView(viewContext);
            mocks.VerifyAll();

            string content = sb.ToString();

            Assert.That(content, Contains.InOrder(
                            "<div>",
                            "Regular text ${This.isnt.code < 0}",
                            "<var dummy=\"This isn't a variable\" />",
                            "</div>"));
            Assert.IsFalse(content.Contains("<ignore>"));
            Assert.IsFalse(content.Contains("</ignore>"));
        }
Exemplo n.º 13
0
        public void AddViewDataMoreThanOnce()
        {
            mocks.ReplayAll();
            var viewData = new StubViewData {
                { "comment", new Comment {
                      Text = "Hello world"
                  } }
            };
            var viewContext = MakeViewContext("addviewdatamorethanonce", null, viewData);

            factory.RenderView(viewContext);
            mocks.VerifyAll();

            string content = sb.ToString();

            Assert.That(content, Contains.InOrder(
                            "<div>Hello world</div>",
                            "<div>\r\n  Again: Hello world\r\n</div>"));
        }
Exemplo n.º 14
0
        public void ConditionalAttributeDelimitedBySpaces()
        {
            mocks.ReplayAll();
            var viewContext = MakeViewContext("ConditionalAttributeDelimitedBySpaces", null);

            factory.RenderView(viewContext);
            mocks.VerifyAll();
            string content = sb.ToString();

            Assert.IsFalse(content.Contains("broken"));
            Assert.That(content, Contains.InOrder(
                            "<h1 class=\"one three\"/>",
                            "<h2/>",
                            "<h3 class=\" two three\"/>",
                            "<h4 class=\"one three\"/>",
                            "<h5 class=\"one two\"/>",
                            "<h6/>",
                            "<h7 class=\"one&two<three\"/>"));
        }
Exemplo n.º 15
0
        public void Markdown()
        {
            mocks.ReplayAll();
            var viewContext = MakeViewContext("markdown", null);

            factory.RenderView(viewContext);
            mocks.VerifyAll();

            string content = sb.ToString();

            Assert.That(content, Contains.InOrder(
                            "<pre><code>", "code block on the first line", "</code></pre>",
                            "<p>", "Regular text.", "</p>",
                            "<pre><code>", "code block indented by spaces", "</code></pre>",
                            "<p>", "Regular text.", "</p>",
                            "<pre><code>", "the lines in this block",
                            "all contain trailing spaces", "</code></pre>",
                            "<p>", "Regular Text.", "</p>",
                            "<pre><code>", "code block on the last line", "</code></pre>"));
        }
Exemplo n.º 16
0
        public void ConditionalTestElement()
        {
            mocks.ReplayAll();
            var viewContext = MakeViewContext("testelement", null);

            factory.RenderView(viewContext);
            mocks.VerifyAll();

            string content = sb.ToString();

            Assert.That(content, Contains.InOrder(
                            "<p>out-1</p>",
                            "<p>out-2</p>",
                            "<p>out-3</p>",
                            "<p>out-4</p>",
                            "<p>out-5</p>",
                            "<p>out-6</p>"));

            Assert.IsFalse(content.Contains("fail"));
        }
Exemplo n.º 17
0
        public void LateBoundEvalResolvesViewData()
        {
            mocks.ReplayAll();
            var viewData = new StubViewData()
            {
                { "alpha", "<strong>hi</strong>" },
                { "beta", "yadda" }
            };
            var viewContext = MakeViewContext("LateBoundEvalResolvesViewData", null, viewData);

            factory.RenderView(viewContext);
            mocks.VerifyAll();
            string content = sb.ToString();

            Assert.That(content, Contains.InOrder(
                            "<p><strong>hi</strong></p>",
                            "<p>&lt;strong&gt;hi&lt;/strong&gt;</p>",
                            "yadda",
                            "<p>42</p>"));
        }
Exemplo n.º 18
0
        public void OnceAttribute()
        {
            mocks.ReplayAll();
            var viewContext = MakeViewContext("OnceAttribute", null);

            factory.RenderView(viewContext);
            mocks.VerifyAll();
            string content = sb.ToString();

            Assert.That(content, Contains.InOrder(
                            "foo1",
                            "bar0",
                            "quux2",
                            "a1"));

            Assert.IsFalse(content.Contains("foo2"));
            Assert.IsFalse(content.Contains("foo3"));
            Assert.IsFalse(content.Contains("bar1"));
            Assert.IsFalse(content.Contains("bar3"));
            Assert.IsFalse(content.Contains("a2"));
        }
Exemplo n.º 19
0
        public void TestForEachIndex()
        {
            mocks.ReplayAll();
            var viewContext = MakeViewContext("foreachindex", null);

            factory.RenderView(viewContext);
            mocks.VerifyAll();

            string content = sb.ToString();

            Assert.That(content, Contains.InOrder(
                            "<p>0: Alpha</p>",
                            "<p>1: Beta</p>",
                            "<p>2: Gamma</p>",
                            "<p>3: Delta</p>",
                            "<li ", "class='even'>Alpha</li>",
                            "<li ", "class='odd'>Beta</li>",
                            "<li ", "class='even'>Gamma</li>",
                            "<li ", "class='odd'>Delta</li>"
                            ));
        }
Exemplo n.º 20
0
        public void AlternateViewdataSyntax()
        {
            mocks.ReplayAll();
            var viewData = new StubViewData <IList <string> > {
                { "my-data", "alpha" }
            };

            viewData.Model = new[] { "beta", "gamma", "delta" };

            var viewContext = MakeViewContext("alternate-viewdata-syntax", null, viewData);

            factory.RenderView(viewContext);
            mocks.VerifyAll();
            string content = sb.ToString();

            Assert.That(content, Contains.InOrder(
                            "<p>", "alpha", "</p>",
                            "<p>", "beta", "</p>",
                            "<p>", "gamma", "</p>",
                            "<p>", "delta", "</p>"
                            ));
        }
Exemplo n.º 21
0
        public void OnceAttributeWorksOnSpecialNodes()
        {
            mocks.ReplayAll();
            var viewContext = MakeViewContext("OnceAttributeWorksOnSpecialNodes", null);

            factory.RenderView(viewContext);
            mocks.VerifyAll();
            string content = sb.ToString();

            Assert.That(content, Contains.InOrder(
                            "<p>name-0-alpha</p>",
                            "<span>foo1</span>",
                            "<span>bar0</span>",
                            "<span>quux2</span>"));

            Assert.IsFalse(content.Contains("name-1"));
            Assert.IsFalse(content.Contains("name-2"));
            Assert.IsFalse(content.Contains("foo2"));
            Assert.IsFalse(content.Contains("foo3"));
            Assert.IsFalse(content.Contains("bar1"));
            Assert.IsFalse(content.Contains("bar3"));
        }
Exemplo n.º 22
0
        public void RenderPartialWithContainedContent()
        {
            mocks.ReplayAll();
            var viewContext = MakeViewContext("render-partial-with-contained-content", null);

            factory.RenderView(viewContext);
            mocks.VerifyAll();
            string content = sb.ToString();

            Assert.That(content, Contains.InOrder(
                            "xbox",
                            "xtop",
                            "xb1",
                            "xb2",
                            "xb3",
                            "xb4",
                            "xboxcontent",
                            "Hello World",
                            "xbottom",
                            "xb4",
                            "xb3",
                            "xb2",
                            "xb1"));
        }