Skip to content

Commit 80b72c8

Browse files
committed
chore: complexity unit tests
1 parent f7980af commit 80b72c8

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
}

0 commit comments

Comments
 (0)