|
5 | 5 |
|
6 | 6 | namespace ObjectSemantics.NET.Tests |
7 | 7 | { |
8 | | - public class LoopFunctionTests |
| 8 | + public class EnumerableLoopTests |
9 | 9 | { |
10 | 10 |
|
11 | 11 | [Fact] |
@@ -174,5 +174,49 @@ John Doe Invoices |
174 | 174 | Assert.Equal(expectedResult, generatedTemplate, false, true, true); |
175 | 175 | } |
176 | 176 |
|
| 177 | + [Fact] |
| 178 | + public void Should_Map_Array_Of_String_With_Formatting() |
| 179 | + { |
| 180 | + //Create Model |
| 181 | + Student student = new Student |
| 182 | + { |
| 183 | + ArrayOfString = new string[] |
| 184 | + { |
| 185 | + "String 001", |
| 186 | + "String 002" |
| 187 | + } |
| 188 | + }; |
| 189 | + //Template |
| 190 | + var template = new ObjectSemanticsTemplate |
| 191 | + { |
| 192 | + FileContents = @"{{ #foreach(ArrayOfString) }} {{ . }} | {{ .:uppercase }} {{ #endforeach }}" |
| 193 | + }; |
| 194 | + string generatedTemplate = template.Map(student); |
| 195 | + string expectedResult = " String 001 | STRING 001 String 002 | STRING 002 "; |
| 196 | + Assert.Equal(expectedResult, generatedTemplate, false, true, true); |
| 197 | + } |
| 198 | + |
| 199 | + |
| 200 | + [Fact] |
| 201 | + public void Should_Map_Array_Of_Double_With_Formatting_Test() |
| 202 | + { |
| 203 | + //Create Model |
| 204 | + Student student = new Student |
| 205 | + { |
| 206 | + ArrayOfDouble = new double[] |
| 207 | + { |
| 208 | + 1000.15, |
| 209 | + 2000.22 |
| 210 | + } |
| 211 | + }; |
| 212 | + //Template |
| 213 | + var template = new ObjectSemanticsTemplate |
| 214 | + { |
| 215 | + FileContents = @"{{ #foreach(ArrayOfDouble) }} {{ . }} | {{ .:N0 }} {{ #endforeach }}" |
| 216 | + }; |
| 217 | + string generatedTemplate = template.Map(student); |
| 218 | + string expectedResult = " 1000.15 | 1,000 2000.22 | 2,000 "; |
| 219 | + Assert.Equal(expectedResult, generatedTemplate, false, true, true); |
| 220 | + } |
177 | 221 | } |
178 | 222 | } |
0 commit comments