public void Should_render_block_when_ifnot_statement_returns_false()
        {
            const string input = @"<html><head></head><body>@IfNot.HasUsers;<p>No users found!</p>@EndIf;<ul>@Each.Users;<li>Hello @Current;, @Model.Name; says hello!</li>@EndEach;</ul></body></html>";
            var model = new FakeModel("Nancy", new List<string>());

            var output = viewEngine.Render(input, model, this.fakeHost);

            Assert.Equal(@"<html><head></head><body><p>No users found!</p><ul></ul></body></html>", output);
        }
        public void Should_render_block_when_if_statement_returns_true()
        {
            const string input = @"<html><head></head><body>@If.HasUsers;<ul>@Each.Users;<li>Hello @Current;, @Model.Name; says hello!</li>@EndEach;</ul>@EndIf;</body></html>";
            var model = new FakeModel("Nancy", new List<string>() { "Bob", "Jim", "Bill" });

            var output = viewEngine.Render(input, model, this.fakeHost);

            Assert.Equal(@"<html><head></head><body><ul><li>Hello Bob, Nancy says hello!</li><li>Hello Jim, Nancy says hello!</li><li>Hello Bill, Nancy says hello!</li></ul></body></html>", output);
        }
        public void Should_allow_if_and_endif_without_semi_colon()
        {
            const string input = @"<html><head></head><body>@If.HasUsers<ul>@Each.Users;<li>Hello @Current;, @Model.Name; says hello!</li>@EndEach;</ul>@EndIf</body></html>";
            var model = new FakeModel("Nancy", new List<string>() { "Bob", "Jim", "Bill" });

            var output = viewEngine.Render(input, model, this.fakeHost);

            Assert.Equal(@"<html><head></head><body><ul><li>Hello Bob, Nancy says hello!</li><li>Hello Jim, Nancy says hello!</li><li>Hello Bill, Nancy says hello!</li></ul></body></html>", output);
        }
        public void Should_allow_substitutions_to_work_with_standard_objects()
        {
            const string input = @"<html><head></head><body><ul>@Each.Users;<li>Hello @Current;, @Model.Name; says hello!</li>@EndEach;</ul></body></html>";
            var model = new FakeModel("Nancy", new List<string>() { "Bob", "Jim", "Bill" });

            var output = viewEngine.Render(input, model, this.fakeHost);

            Assert.Equal(@"<html><head></head><body><ul><li>Hello Bob, Nancy says hello!</li><li>Hello Jim, Nancy says hello!</li><li>Hello Bill, Nancy says hello!</li></ul></body></html>", output);
        }
Exemplo n.º 5
0
        public void Should_support_each_block_with_model_as_model_source()
        {
            const string input = @"<html><head></head><body><ul>@Each.Model.Users;<li>Hello @Current;, @Model.Name; says hello!</li>@EndEach;</ul></body></html>";
            var model = new FakeModel("Nancy", new List<string>() { "Bob", "Jim", "Bill" });

            ((FakeViewEngineHost)this.fakeHost).Context = new FakeModel("NancyContext", new List<string>());

            var output = viewEngine.Render(input, model, this.fakeHost);

            Assert.Equal(@"<html><head></head><body><ul><li>Hello Bob, Nancy says hello!</li><li>Hello Jim, Nancy says hello!</li><li>Hello Bill, Nancy says hello!</li></ul></body></html>", output);
        }
Exemplo n.º 6
0
        public void Should_allow_if_and_endif_and_model_model_source()
        {
            const string input = @"<html><head></head><body>@If.Model.HasUsers;Users found!@EndIf</body></html>";
            var model = new FakeModel("Nancy", new List<string>() { "Bob", "Jim", "Bill" });

            ((FakeViewEngineHost)this.fakeHost).Context = new FakeModel("NancyContext", new List<string>());

            var output = viewEngine.Render(input, model, this.fakeHost);

            Assert.Equal(@"<html><head></head><body>Users found!</body></html>", output);
        }
Exemplo n.º 7
0
        public void Should_stuffrender_block_when_ifnot_statement_returns_false()
        {
            const string input = @"<html><head></head><body>@IfNot.Context.HasUsers;<p>No users found!</p>@EndIf;</body></html>";

            var model = new FakeModel("Nancy", new List<string>() { "Nancy " });

            ((FakeViewEngineHost)this.fakeHost).Context = new FakeModel("NancyContext", new List<string>());

            var output = viewEngine.Render(input, model, this.fakeHost);

            Assert.Equal(@"<html><head></head><body><p>No users found!</p></body></html>", output);
        }
Exemplo n.º 8
0
        public void Should_not_conflict_when_if_and_ifNot_statements_combined_but_not_nested()
        {
            const string input = @"<html><head></head><body>@IfNot.HasUsers;<p>No users found!</p>@EndIf;@If.HasUsers;<ul>@Each.Users;<li>Hello @Current;, @Model.Name; says hello!</li>@EndEach;</ul>@EndIf;</body></html>";
            var model = new FakeModel("Nancy", new List<string>());

            var output = viewEngine.Render(input, model);

            Assert.Equal(@"<html><head></head><body><p>No users found!</p></body></html>", output);
        }
        public void Should_allow_ifnot_and_endif_without_semi_colon()
        {
            // Given
            const string input = @"<html><head></head><body>@IfNot.HasUsers<p>No users found!</p>@EndIf<ul>@Each.Users;<li>Hello @Current;, @Model.Name; says hello!</li>@EndEach;</ul></body></html>";
            var model = new FakeModel("Nancy", new List<string>() { "Bob", "Jim", "Bill" });

            // When
            var output = viewEngine.Render(input, model);

            // Then
            Assert.Equal(@"<html><head></head><body><ul><li>Hello Bob, Nancy says hello!</li><li>Hello Jim, Nancy says hello!</li><li>Hello Bill, Nancy says hello!</li></ul></body></html>", output);
        }
        public void Should_not_render_block_when_ifnot_statements_returns_true()
        {
            // Given
            const string input = @"<html><head></head><body>@IfNot.HasUsers;<p>No users found!</p>@EndIf;<ul>@Each.Users;<li>Hello @Current;, @Model.Name; says hello!</li>@EndEach;</ul></body></html>";
            var model = new FakeModel("Nancy", new List<string>() { "Bob", "Jim", "Bill" });

            // When
            var output = viewEngine.Render(input, model);

            // Then
            Assert.Equal(@"<html><head></head><body><ul><li>Hello Bob, Nancy says hello!</li><li>Hello Jim, Nancy says hello!</li><li>Hello Bill, Nancy says hello!</li></ul></body></html>", output);
        }
        public void Should_not_render_block_when_if_statement_returns_false()
        {
            // Given
            const string input = @"<html><head></head><body>@If.HasUsers;<ul>@Each.Users;<li>Hello @Current;, @Model.Name; says hello!</li>@EndEach;</ul>@EndIf;</body></html>";
            var model = new FakeModel("Nancy", new List<string>());

            // When
            var output = viewEngine.Render(input, model);

            // Then
            Assert.Equal(@"<html><head></head><body></body></html>", output);
        }