@@ -29,7 +29,7 @@ public void Should_Map_Object_To_Template_From_TemplateObject()
2929 Assert . Equal ( expectedString , generatedTemplate , false , true , true ) ;
3030 }
3131
32- // Loop Object Tests
32+ #region Loop Conditions Tests
3333 [ Fact ]
3434 public void Should_Map_Enumerable_Collection_In_Object ( )
3535 {
@@ -104,7 +104,7 @@ public void Should_Map_Enumerable_Collection_SingleLine_Test()
104104
105105
106106 [ Fact ]
107- public void Should_Map_Multiple_Enumerable_Collection_On_Same_Template ( )
107+ public void Should_Map_Multiple_Same_Property_Enumerable_Collection_On_Same_Template ( )
108108 {
109109 //Create Model
110110 Student student = new Student
@@ -146,6 +146,58 @@ John Doe Invoices
146146 Assert . Equal ( expectedResult , generatedTemplate , false , true , true ) ;
147147 }
148148
149+
150+ [ Fact ]
151+ public void Should_Map_Multiple_Different_Property_Enumerable_Collection_On_Same_Template ( )
152+ {
153+ //Create Model
154+ Student student = new Student
155+ {
156+ StudentName = "John Doe" ,
157+ Invoices = new List < Invoice >
158+ {
159+ new Invoice { Id = 2 , RefNo = "INV_002" , Narration = "Grade II Fees Invoice" , Amount = 2000 , InvoiceDate = new DateTime ( 2023 , 04 , 01 ) } ,
160+ new Invoice { Id = 1 , RefNo = "INV_001" , Narration = "Grade I Fees Invoice" , Amount = 320 , InvoiceDate = new DateTime ( 2022 , 08 , 01 ) }
161+ } ,
162+ StudentClockInDetails = new List < StudentClockInDetail >
163+ {
164+ new StudentClockInDetail { LastClockedInDate = new DateTime ( 2024 , 04 , 01 ) , LastClockedInPoints = 10 } ,
165+ new StudentClockInDetail { LastClockedInDate = new DateTime ( 2024 , 04 , 02 ) , LastClockedInPoints = 30 }
166+ }
167+ } ;
168+ //Template
169+ var template = new ObjectSemanticsTemplate
170+ {
171+ FileContents = @"
172+ {{ StudentName }} Invoices
173+ LOOP #1
174+ {{ #foreach(invoices) }}
175+ <h5>{{ Id }} On Loop #1</h5>
176+ {{ #endforeach }}
177+ LOOP #2
178+ {{ #foreach(studentClockInDetails) }}
179+ <h5>Got {{ LastClockedInPoints }} for {{ LastClockedInDate:yyyy-MM-dd }}</h5>
180+ {{ #endforeach }}"
181+ } ;
182+ string generatedTemplate = TemplateMapper . Map ( student , template ) ;
183+ string expectedResult = @"
184+ John Doe Invoices
185+ LOOP #1
186+
187+ <h5>2 On Loop #1</h5>
188+
189+ <h5>1 On Loop #1</h5>
190+ LOOP #2
191+
192+ <h5>Got 10 for 2024-04-01</h5>
193+
194+ <h5>Got 30 for 2024-04-02</h5>" ;
195+
196+ Assert . Equal ( expectedResult , generatedTemplate , false , true , true ) ;
197+ }
198+
199+ #endregion
200+
149201 [ Fact ]
150202 public void Should_Map_Additional_Parameters ( )
151203 {
0 commit comments