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_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); }
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_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); }
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); }
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); }