@@ -118,6 +118,8 @@ public void TestForeachLoopInTables()
118118 var xml = Helpers . GetZipFileContent ( path , "word/document.xml" ) ;
119119 Assert . Contains ( @"Discussion requirement part2 and development" , xml ) ;
120120 Assert . Contains ( @"Discussion requirement part1" , xml ) ;
121+ Assert . Contains (
122+ "Air way to the Airplane | Parking way to the Car / Hotel way to the Room, Food way to the Plate" , xml ) ;
121123 }
122124
123125 [ Fact ]
@@ -152,5 +154,118 @@ public void MiniWordIfStatement_FirstIf()
152154 Assert . Contains ( "CreateDate is not less than 2021" , docXml ) ;
153155 Assert . DoesNotContain ( "CreateDate is not greater than 2021" , docXml ) ;
154156 }
157+
158+ [ Fact ]
159+ public void TestForeachLoopInTablesWithIfStatement ( )
160+ {
161+ var path = PathHelper . GetTempFilePath ( ) ;
162+ var templatePath = PathHelper . GetFile ( "TestForeachInTablesWithIfStatementDemo.docx" ) ;
163+ var value = new Dictionary < string , object > ( )
164+ {
165+ [ "TripHs" ] = new List < Dictionary < string , object > >
166+ {
167+ new Dictionary < string , object >
168+ {
169+ { "sDate" , DateTime . Parse ( "2022-09-08 08:30:00" ) } ,
170+ { "eDate" , DateTime . Parse ( "2022-09-08 15:00:00" ) } ,
171+ { "How" , "Discussion requirement part1" } ,
172+ {
173+ "Details" , new List < MiniWordForeach > ( )
174+ {
175+ new MiniWordForeach ( )
176+ {
177+ Value = new Dictionary < string , object > ( )
178+ {
179+ { "Text" , "Air" } ,
180+ { "Value" , "Airplane" }
181+ } ,
182+ Separator = " | "
183+ } ,
184+ new MiniWordForeach ( )
185+ {
186+ Value = new Dictionary < string , object > ( )
187+ {
188+ { "Text" , "Parking" } ,
189+ { "Value" , "Car" }
190+ } ,
191+ Separator = " / "
192+ } ,
193+ new MiniWordForeach ( )
194+ {
195+ Value = new Dictionary < string , object > ( )
196+ {
197+ { "Text" , "Hotel" } ,
198+ { "Value" , "Room" }
199+ } ,
200+ Separator = ", "
201+ } ,
202+ new MiniWordForeach ( )
203+ {
204+ Value = new Dictionary < string , object > ( )
205+ {
206+ { "Text" , "Food" } ,
207+ { "Value" , "Plate" }
208+ } ,
209+ Separator = ""
210+ }
211+ }
212+ }
213+ } ,
214+ new Dictionary < string , object >
215+ {
216+ { "sDate" , DateTime . Parse ( "2022-09-09 08:30:00" ) } ,
217+ { "eDate" , DateTime . Parse ( "2022-09-09 17:00:00" ) } ,
218+ { "How" , "Discussion requirement part2 and development" } ,
219+ {
220+ "Details" , new List < MiniWordForeach > ( )
221+ {
222+ new MiniWordForeach ( )
223+ {
224+ Value = new Dictionary < string , object > ( )
225+ {
226+ { "Text" , "Air" } ,
227+ { "Value" , "Airplane" }
228+ } ,
229+ Separator = " | "
230+ } ,
231+ new MiniWordForeach ( )
232+ {
233+ Value = new Dictionary < string , object > ( )
234+ {
235+ { "Text" , "Parking" } ,
236+ { "Value" , "Car" }
237+ } ,
238+ Separator = " / "
239+ } ,
240+ new MiniWordForeach ( )
241+ {
242+ Value = new Dictionary < string , object > ( )
243+ {
244+ { "Text" , "Hotel" } ,
245+ { "Value" , "Room" }
246+ } ,
247+ Separator = ", "
248+ } ,
249+ new MiniWordForeach ( )
250+ {
251+ Value = new Dictionary < string , object > ( )
252+ {
253+ { "Text" , "Food" } ,
254+ { "Value" , "Plate" }
255+ } ,
256+ Separator = ""
257+ }
258+ }
259+ }
260+ }
261+ }
262+ } ;
263+ MiniWord . SaveAsByTemplate ( path , templatePath , value ) ;
264+ //System.Diagnostics.Process.Start("explorer.exe", path);
265+ var xml = Helpers . GetZipFileContent ( path , "word/document.xml" ) ;
266+ Assert . Contains ( @"Discussion requirement part2 and development" , xml ) ;
267+ Assert . Contains ( @"Discussion requirement part1" , xml ) ;
268+ Assert . Contains ( "Air way to the Airplane | Hotel way to the Room" , xml ) ;
269+ }
155270 }
156271}
0 commit comments