Skip to content

Commit 6b1706b

Browse files
authored
Merge pull request #20 from swagfin/optimized-engine
chore: multi-if statement blocks
2 parents 734f454 + fa4f37d commit 6b1706b

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

ObjectSemantics.NET.Tests/IfConditionTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,23 @@ public void Should_Evaluate_String_Conditions_If_Blocks(string name, string expe
112112
string result = person.Map(template);
113113
Assert.Equal(expected, result);
114114
}
115+
116+
[Theory]
117+
[InlineData(40, "[Adult]|[CanTakeAlcohol]")]
118+
[InlineData(18, "[Adult]|[CanTakeAlcohol]")]
119+
[InlineData(0, "[Minor]|[NoAlcohol]")]
120+
[InlineData(-7, "[Minor]|[NoAlcohol]")]
121+
public void Should_Render_Multiple_If_Condition_Statements(int age, string expected)
122+
{
123+
Person person = new Person
124+
{
125+
Age = age
126+
};
127+
128+
string template = @"{{ #if(Age >= 18) }}[Adult]{{ #else }}[Minor]{{ #endif }}|{{ #if(Age < 18) }}[NoAlcohol]{{ #else }}[CanTakeAlcohol]{{ #endif }}";
129+
130+
string result = person.Map(template);
131+
Assert.Equal(expected, result);
132+
}
115133
}
116134
}

0 commit comments

Comments
 (0)