public async Task TestIfFromVariable() { const object nullValue = null; await Helper.AssertTemplateResultAsync("", "{% if var %} NO {% endif %}", Hash.FromAnonymousObject(new { var = false })); await Helper.AssertTemplateResultAsync("", "{% if var %} NO {% endif %}", Hash.FromAnonymousObject(new { var = nullValue })); await Helper.AssertTemplateResultAsync("", "{% if foo.bar %} NO {% endif %}", Hash.FromAnonymousObject(new { foo = Hash.FromAnonymousObject(new { bar = false }) })); await Helper.AssertTemplateResultAsync("", "{% if foo.bar %} NO {% endif %}", Hash.FromAnonymousObject(new { foo = new Hash() })); await Helper.AssertTemplateResultAsync("", "{% if foo.bar %} NO {% endif %}", Hash.FromAnonymousObject(new { foo = nullValue })); await Helper.AssertTemplateResultAsync("", "{% if foo.bar %} NO {% endif %}", Hash.FromAnonymousObject(new { foo = true })); await Helper.AssertTemplateResultAsync(" YES ", "{% if var %} YES {% endif %}", Hash.FromAnonymousObject(new { var = "text" })); await Helper.AssertTemplateResultAsync(" YES ", "{% if var %} YES {% endif %}", Hash.FromAnonymousObject(new { var = true })); await Helper.AssertTemplateResultAsync(" YES ", "{% if var %} YES {% endif %}", Hash.FromAnonymousObject(new { var = 1 })); await Helper.AssertTemplateResultAsync(" YES ", "{% if var %} YES {% endif %}", Hash.FromAnonymousObject(new { var = new Hash() })); await Helper.AssertTemplateResultAsync(" YES ", "{% if var %} YES {% endif %}", Hash.FromAnonymousObject(new { var = new object[] { } })); await Helper.AssertTemplateResultAsync(" YES ", "{% if 'foo' %} YES {% endif %}"); await Helper.AssertTemplateResultAsync(" YES ", "{% if foo.bar %} YES {% endif %}", Hash.FromAnonymousObject(new { foo = Hash.FromAnonymousObject(new { bar = true }) })); await Helper.AssertTemplateResultAsync(" YES ", "{% if foo.bar %} YES {% endif %}", Hash.FromAnonymousObject(new { foo = Hash.FromAnonymousObject(new { bar = "text" }) })); await Helper.AssertTemplateResultAsync(" YES ", "{% if foo.bar %} YES {% endif %}", Hash.FromAnonymousObject(new { foo = Hash.FromAnonymousObject(new { bar = 1 }) })); await Helper.AssertTemplateResultAsync(" YES ", "{% if foo.bar %} YES {% endif %}", Hash.FromAnonymousObject(new { foo = Hash.FromAnonymousObject(new { bar = new Hash() }) })); await Helper.AssertTemplateResultAsync(" YES ", "{% if foo.bar %} YES {% endif %}", Hash.FromAnonymousObject(new { foo = Hash.FromAnonymousObject(new { bar = new object[] { } }) })); await Helper.AssertTemplateResultAsync(" YES ", "{% if var %} NO {% else %} YES {% endif %}", Hash.FromAnonymousObject(new { var = false })); await Helper.AssertTemplateResultAsync(" YES ", "{% if var %} NO {% else %} YES {% endif %}", Hash.FromAnonymousObject(new { var = nullValue })); await Helper.AssertTemplateResultAsync(" YES ", "{% if var %} YES {% else %} NO {% endif %}", Hash.FromAnonymousObject(new { var = true })); await Helper.AssertTemplateResultAsync(" YES ", "{% if 'foo' %} YES {% else %} NO {% endif %}", Hash.FromAnonymousObject(new { var = "text" })); await Helper.AssertTemplateResultAsync(" YES ", "{% if foo.bar %} NO {% else %} YES {% endif %}", Hash.FromAnonymousObject(new { foo = Hash.FromAnonymousObject(new { bar = false }) })); await Helper.AssertTemplateResultAsync(" YES ", "{% if foo.bar %} YES {% else %} NO {% endif %}", Hash.FromAnonymousObject(new { foo = Hash.FromAnonymousObject(new { bar = true }) })); await Helper.AssertTemplateResultAsync(" YES ", "{% if foo.bar %} YES {% else %} NO {% endif %}", Hash.FromAnonymousObject(new { foo = Hash.FromAnonymousObject(new { bar = "text" }) })); await Helper.AssertTemplateResultAsync(" YES ", "{% if foo.bar %} NO {% else %} YES {% endif %}", Hash.FromAnonymousObject(new { foo = Hash.FromAnonymousObject(new { notbar = true }) })); await Helper.AssertTemplateResultAsync(" YES ", "{% if foo.bar %} NO {% else %} YES {% endif %}", Hash.FromAnonymousObject(new { foo = new Hash() })); await Helper.AssertTemplateResultAsync(" YES ", "{% if foo.bar %} NO {% else %} YES {% endif %}", Hash.FromAnonymousObject(new { notfoo = Hash.FromAnonymousObject(new { bar = true }) })); }
public async Task TestIfOr() { await Helper.AssertTemplateResultAsync(" YES ", "{% if a or b %} YES {% endif %}", Hash.FromAnonymousObject(new { a = true, b = true })); await Helper.AssertTemplateResultAsync(" YES ", "{% if a or b %} YES {% endif %}", Hash.FromAnonymousObject(new { a = true, b = false })); await Helper.AssertTemplateResultAsync(" YES ", "{% if a or b %} YES {% endif %}", Hash.FromAnonymousObject(new { a = false, b = true })); await Helper.AssertTemplateResultAsync("", "{% if a or b %} YES {% endif %}", Hash.FromAnonymousObject(new { a = false, b = false })); await Helper.AssertTemplateResultAsync(" YES ", "{% if a or b or c %} YES {% endif %}", Hash.FromAnonymousObject(new { a = false, b = false, c = true })); await Helper.AssertTemplateResultAsync("", "{% if a or b or c %} YES {% endif %}", Hash.FromAnonymousObject(new { a = false, b = false, c = false })); }
public async Task TestHashMissGeneratesFalse() { await Helper.AssertTemplateResultAsync("", "{% if foo.bar %} NO {% endif %}", Hash.FromAnonymousObject(new { foo = new Hash() })); }
public async Task TestIfBoolean() { await Helper.AssertTemplateResultAsync(" YES ", "{% if var %} YES {% endif %}", Hash.FromAnonymousObject(new { var = true })); }