File tree Expand file tree Collapse file tree
ObjectSemantics.NET.Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using ObjectSemantics . NET . Tests . MoqModels ;
2+ using System . Collections . Generic ;
3+ using Xunit ;
4+
5+ namespace ObjectSemantics . NET . Tests
6+ {
7+ public class ComplexityTests
8+ {
9+
10+ [ Fact ]
11+ public void Should_Handle_ForEach_Loop_Inside_If_Block_Inline ( )
12+ {
13+ Person person = new Person
14+ {
15+ MyCars = new List < Car >
16+ {
17+ new Car { Make = "BMW" } ,
18+ new Car { Make = "Rolls-Royce" }
19+ }
20+ } ;
21+
22+ string template = @"{{ #if(MyCars > 0) }}{{ #foreach(MyCars) }}[{{ Make }}]{{ #endforeach }}{{ #endif }}" ;
23+
24+ string result = person . Map ( template ) ;
25+
26+ string expected = "[BMW][Rolls-Royce]" ;
27+ Assert . Equal ( expected , result ) ;
28+ }
29+
30+
31+ [ Fact ]
32+ public void Should_Handle_ForEach_Loop_Inside_If_Block_Multiline ( )
33+ {
34+ Person person = new Person
35+ {
36+ MyCars = new List < Car >
37+ {
38+ new Car { Make = "Toyota" } ,
39+ new Car { Make = "BMW" }
40+ }
41+ } ;
42+
43+ string template = @"
44+ {{ #if(MyCars > 0) }}
45+ {{ #foreach(MyCars) }}
46+ - {{ Make:uppercase }}
47+ {{ #endforeach }}
48+ {{ #endif }}" ;
49+
50+ string result = person . Map ( template ) ;
51+
52+ string expected = @"
53+
54+
55+ - TOYOTA
56+
57+ - BMW
58+
59+ " ;
60+ Assert . Equal ( expected , result ) ;
61+ }
62+ }
63+ }
You can’t perform that action at this time.
0 commit comments