@@ -260,7 +260,7 @@ public void Should_Act_On_IfCondition_SingleLine()
260260 //Template
261261 var template = new ObjectSemanticsTemplate
262262 {
263- FileContents = "IsEnabled: {{ if-start:invoices( !=null) }}YES{{ if-end:invoices }}"
263+ FileContents = "IsEnabled: {{ #if(invoices !=null) }}YES{{ #endif }}"
264264 } ;
265265 string generatedTemplate = TemplateMapper . Map ( student , template ) ;
266266 string expectedResult = "IsEnabled: YES" ;
@@ -284,7 +284,7 @@ public void Should_Act_On_IfCondition_SingleLine_With_Attribute()
284284 //Template
285285 var template = new ObjectSemanticsTemplate
286286 {
287- FileContents = "InvoicedPerson: {{ if-start:invoices( !=null) }}{{StudentName}}{{ if-end:invoices }}"
287+ FileContents = "InvoicedPerson: {{ #if(invoices !=null) }}{{StudentName}}{{ #endif }}"
288288 } ;
289289 string generatedTemplate = TemplateMapper . Map ( student , template ) ;
290290 string expectedResult = "InvoicedPerson: John Doe" ;
@@ -309,9 +309,9 @@ public void Should_Act_On_IfCondition_MultiLine()
309309 var template = new ObjectSemanticsTemplate
310310 {
311311 FileContents = @"status
312- {{ if-start:invoices( !=null) }}
312+ {{ #if(invoices !=null) }}
313313<h4>condition--passed</h4>
314- {{ if-end:invoices }}"
314+ {{ #endif }}"
315315 } ;
316316 string generatedTemplate = TemplateMapper . Map ( student , template ) ;
317317 string expectedResult = "status\r \n \r \n <h4>condition--passed</h4>\r \n " ;
@@ -336,9 +336,9 @@ public void Should_Act_On_IfCondition_MultiLine_With_Attribute()
336336 var template = new ObjectSemanticsTemplate
337337 {
338338 FileContents = @"status
339- {{ if-start:invoices( !=null) }}
339+ {{ #if(invoices !=null) }}
340340<h4>Hi, I have invoices for {{ StudentName }} </h4>
341- {{ if-end:invoices }}"
341+ {{ #endif }}"
342342 } ;
343343 string generatedTemplate = TemplateMapper . Map ( student , template ) ;
344344 string expectedResult = "status\r \n \r \n <h4>Hi, I have invoices for John Doe </h4>\r \n " ;
@@ -363,15 +363,15 @@ public void Should_Act_On_IfCondition_Having_Loop_As_Child()
363363 var template = new ObjectSemanticsTemplate
364364 {
365365 FileContents = @"
366- {{ if-start:invoices(!= null) }}
366+ {{ #if (invoices != null) }}
367367{{ StudentName }} Invoices
368368{{ for-each-start:invoices }}
369369<tr>
370370 <td>{{ Id }}</td>
371371 <td>{{ RefNo }}</td>
372372</tr>
373373{{ for-each-end:invoices }}
374- {{ if-end:invoices }}"
374+ {{ #endif }}"
375375 } ;
376376 string generatedTemplate = TemplateMapper . Map ( student , template ) ;
377377 string expectedResult = "\r \n \r \n John Doe Invoices" +
@@ -390,7 +390,7 @@ public void Should_Act_On_IfCondition_Having_Loop_As_Child()
390390 //#Match =, !=, >, >=, <, and <=.
391391
392392 [ Theory ]
393- [ InlineData ( "=" , 5000 ) ]
393+ [ InlineData ( "== " , 5000 ) ]
394394 [ InlineData ( "!=" , 0 ) ]
395395 [ InlineData ( ">" , 2000 ) ]
396396 [ InlineData ( "<=" , 5001 ) ]
@@ -402,7 +402,7 @@ public void Should_Act_On_IfCondition_Equality_Checks(string condition, double a
402402 //Template
403403 var template = new ObjectSemanticsTemplate
404404 {
405- FileContents = string . Format ( "{2} if-start:balance( {0}{1}) {3} {0} passed {2} if-end:balance {3}" , condition , amount , "{{" , "}}" )
405+ FileContents = string . Format ( "{2} #if(balance {0}{1}) {3} {0} passed {2} #endif {3}" , condition , amount , "{{" , "}}" )
406406 } ;
407407
408408 string expectedResult = string . Format ( " {0} passed " , condition ) ;
@@ -412,8 +412,6 @@ public void Should_Act_On_IfCondition_Equality_Checks(string condition, double a
412412
413413
414414
415-
416-
417415 [ Fact ]
418416 public void Should_Act_On_IfCondition_IEnumerable_Tests_Equall ( )
419417 {
@@ -430,7 +428,7 @@ public void Should_Act_On_IfCondition_IEnumerable_Tests_Equall()
430428 //Template
431429 var template = new ObjectSemanticsTemplate
432430 {
433- FileContents = "{{ if-start:invoices(= 2) }} 2 records {{ if-end:invoices }}"
431+ FileContents = "{{ #if(invoices== 2) }} 2 records {{ #endif }}"
434432 } ;
435433 string generatedTemplate = TemplateMapper . Map ( student , template ) ;
436434 string expectedResult = " 2 records " ;
@@ -454,7 +452,7 @@ public void Should_Act_On_IfCondition_IEnumerable_Tests_NotEqualNull()
454452 //Template
455453 var template = new ObjectSemanticsTemplate
456454 {
457- FileContents = "{{ if-start:invoices( !=null) }} is not NULL {{ if-end:invoices }}"
455+ FileContents = "{{ #if(invoices !=null) }} is not NULL {{ #endif }}"
458456 } ;
459457 string generatedTemplate = TemplateMapper . Map ( student , template ) ;
460458 string expectedResult = " is not NULL " ;
@@ -473,7 +471,7 @@ public void Should_Act_On_IfCondition_IEnumerable_Tests_NULL_Object_Behaviour()
473471 //Template
474472 var template = new ObjectSemanticsTemplate
475473 {
476- FileContents = "{{ if-start:invoices(= null) }} is NULL {{ if-end:invoices }}"
474+ FileContents = "{{ #if(invoices== null) }} is NULL {{ #endif }}"
477475 } ;
478476 string generatedTemplate = TemplateMapper . Map ( student , template ) ;
479477 string expectedResult = " is NULL " ;
@@ -491,7 +489,7 @@ public void Should_Act_On_IfCondition_IEnumerable_Tests_Count_NULL_Object_Behavi
491489 //Template
492490 var template = new ObjectSemanticsTemplate
493491 {
494- FileContents = "{{ if-start:invoices(= 0) }} no records {{ if-end:invoices }}"
492+ FileContents = "{{ #if(invoices== 0) }} no records {{ #endif }}"
495493 } ;
496494 string generatedTemplate = TemplateMapper . Map ( student , template ) ;
497495 string expectedResult = " no records " ;
@@ -510,7 +508,7 @@ public void Should_Act_On_IfCondition_IEnumerable_Tests_Count_Object_Behaviour()
510508 //Template
511509 var template = new ObjectSemanticsTemplate
512510 {
513- FileContents = "{{ if-start:invoices(= null) }} no records {{ if-end:invoices }}"
511+ FileContents = "{{ #if(invoices== null) }} no records {{ #endif }}"
514512 } ;
515513 string generatedTemplate = TemplateMapper . Map ( student , template ) ;
516514 string expectedResult = " no records " ;
@@ -529,7 +527,7 @@ public void Should_Act_On_IfCondition_Having_ElseIf_Inline(double amount)
529527 //Template
530528 var template = new ObjectSemanticsTemplate
531529 {
532- FileContents = "{{ if-start:Balance(= 5000) }} --ok-passed-- {{ else-if }} --error-failed-- {{ if-end:Balance }}"
530+ FileContents = "{{ #if(Balance== 5000) }} --ok-passed-- {{ # else }} --error-failed-- {{ #endif }}"
533531 } ;
534532 string generatedTemplate = TemplateMapper . Map ( student , template ) ;
535533 string expectedResult = ( amount == 5000 ) ? " --ok-passed-- " : " --error-failed-- " ;
@@ -547,11 +545,11 @@ public void Should_Act_On_IfCondition_Having_ElseIf_MultiLine(double amount)
547545 var template = new ObjectSemanticsTemplate
548546 {
549547 FileContents = @"
550- {{ if-start:Balance( =5000) }}
548+ {{ #if(Balance= =5000) }}
551549--ok-passed--
552- {{ else-if }}
550+ {{ # else }}
553551--error-failed--
554- {{ if-end:Balance }}"
552+ {{ #endif }}"
555553 } ;
556554 string generatedTemplate = TemplateMapper . Map ( student , template ) ;
557555 string expectedResult = ( amount == 5000 ) ? "\r \n \r \n --ok-passed--\r \n " : "\r \n \r \n --error-failed--\r \n " ;
@@ -570,11 +568,11 @@ public void Should_Act_On_IfCondition_Having_ElseIf_MultiLine_String_EquallsNull
570568 var template = new ObjectSemanticsTemplate
571569 {
572570 FileContents = @"
573- {{ if-start:StudentName( =NULL) }}
571+ {{ #if(StudentName= =NULL) }}
574572--ok-passed--
575- {{ else-if }}
573+ {{ # else }}
576574--error-failed--
577- {{ if-end:Balance }}"
575+ {{ #endif }}"
578576 } ;
579577 string generatedTemplate = TemplateMapper . Map ( student , template ) ;
580578 string expectedResult = string . IsNullOrEmpty ( studentName ) ? "\r \n \r \n --ok-passed--\r \n " : "\r \n \r \n --error-failed--\r \n " ;
@@ -593,19 +591,18 @@ public void Should_Act_On_IfCondition_Having_ElseIf_MultiLine_String_NotEquallsN
593591 var template = new ObjectSemanticsTemplate
594592 {
595593 FileContents = @"
596- {{ if-start:StudentName( !=NULL) }}
594+ {{ #if(StudentName !=NULL) }}
597595--ok-passed--
598- {{ else-if }}
596+ {{ # else }}
599597--error-failed--
600- {{ if-end:Balance }}"
598+ {{ #endif }}"
601599 } ;
602600 string generatedTemplate = TemplateMapper . Map ( student , template ) ;
603601 string expectedResult = ( ! string . IsNullOrEmpty ( studentName ) ) ? "\r \n \r \n --ok-passed--\r \n " : "\r \n \r \n --error-failed--\r \n " ;
604602 Assert . Equal ( expectedResult , generatedTemplate , false , true , true ) ;
605603 }
606604
607605
608-
609606 [ Theory ]
610607 [ InlineData ( null ) ]
611608 [ InlineData ( "John Doe" ) ]
@@ -618,11 +615,11 @@ public void Should_Act_On_IfCondition_Having_ElseIf_MultiLine_String_Equalls(str
618615 var template = new ObjectSemanticsTemplate
619616 {
620617 FileContents = @"
621- {{ if-start:StudentName( =John Doe) }}
618+ {{ #if(StudentName= =John Doe) }}
622619--ok-passed--
623- {{ else-if }}
620+ {{ # else }}
624621--error-failed--
625- {{ if-end:Balance }}"
622+ {{ #endif }}"
626623 } ;
627624 string generatedTemplate = TemplateMapper . Map ( student , template ) ;
628625 string expectedResult = ( studentName == "John Doe" ) ? "\r \n \r \n --ok-passed--\r \n " : "\r \n \r \n --error-failed--\r \n " ;
@@ -638,7 +635,7 @@ public void Should_Act_On_IfCondition_Simple_Property_String_Equality()
638635 //Template
639636 var template = new ObjectSemanticsTemplate
640637 {
641- FileContents = "{{ if-start:studentName(= John Doe) }} YES, i am John Doe {{ if-end:studentName }}"
638+ FileContents = "{{ #if(studentName== John Doe) }} YES, i am John Doe {{ #endif }}"
642639 } ;
643640 string generatedTemplate = TemplateMapper . Map ( student , template ) ;
644641 string expectedResult = " YES, i am John Doe " ;
@@ -667,16 +664,16 @@ public void Should_Act_On_IfCondition_Having_ElseIf_Having_A_LoopBlock(bool popu
667664 var template = new ObjectSemanticsTemplate
668665 {
669666 FileContents = @"
670- {{ if-start:invoices( =null) }}
667+ {{ #if(invoices= =null) }}
671668-- no invoices found --
672- {{ else-if }}
669+ {{ # else }}
673670{{ for-each-start:invoices }}
674671<tr>
675672 <td>{{ Id }}</td>
676673 <td>{{ RefNo }}</td>
677674</tr>
678675{{ for-each-end:invoices }}
679- {{ if-end:invoices }}"
676+ {{ #endif }}"
680677 } ;
681678 string generatedTemplate = TemplateMapper . Map ( student , template ) ;
682679 string expectedResult = ( populateInvoices ) ? "\r \n " +
@@ -692,6 +689,58 @@ public void Should_Act_On_IfCondition_Having_ElseIf_Having_A_LoopBlock(bool popu
692689 : "\r \n \r \n -- no invoices found --\r \n " ;
693690 Assert . Equal ( expectedResult , generatedTemplate , false , true , true ) ;
694691 }
692+
693+
694+
695+
696+ [ Fact ]
697+ public void Should_Act_On_IfCondition_Having_Multiple_IF_Condition_Blocks_SingleLine ( )
698+ {
699+ //Create Model
700+ Student student = new Student { StudentName = "John Doe" , Balance = 2000 } ;
701+ //Template
702+ var template = new ObjectSemanticsTemplate
703+ {
704+ FileContents = "{{ #if(studentName==John Doe) }} YES, i am John Doe {{ #endif }} | {{ #if(Balance==2000) }} YES, my balance is 2000 {{ #endif }}"
705+ } ;
706+ string generatedTemplate = TemplateMapper . Map ( student , template ) ;
707+ string expectedResult = " YES, i am John Doe | YES, my balance is 2000 " ;
708+ Assert . Equal ( expectedResult , generatedTemplate , false , true , true ) ;
709+ }
710+
711+ [ Theory ]
712+ [ InlineData ( null ) ]
713+ [ InlineData ( "John Doe" ) ]
714+ [ InlineData ( "" ) ]
715+ public void Should_Act_On_IfCondition_Having_Multiple_IF_Condition_Blocks_MultiLine ( string studentName )
716+ {
717+ //Create Model
718+ Student student = new Student { StudentName = studentName } ;
719+ //Template
720+ var template = new ObjectSemanticsTemplate
721+ {
722+ FileContents = @"
723+ #Test 1
724+ {{ #if(StudentName!=NULL) }}
725+ --ok-passed--
726+ {{ #else }}
727+ --error-failed--
728+ {{ #endif }}
729+ #Test 2
730+ {{ #if(StudentName==John Doe) }}
731+ --I am, John Doe--
732+ {{ #else }}
733+ --I am NOT--
734+ {{ #endif }}"
735+
736+ } ;
737+ string generatedTemplate = TemplateMapper . Map ( student , template ) ;
738+ string expectedResult = ( studentName == "John Doe" )
739+ ?
740+ "\r \n #Test 1\r \n \r \n --ok-passed--\r \n \r \n #Test 2\r \n \r \n --I am, John Doe--\r \n "
741+ : "\r \n #Test 1\r \n \r \n --error-failed--\r \n \r \n #Test 2\r \n \r \n --I am NOT--\r \n " ;
742+ Assert . Equal ( expectedResult , generatedTemplate , false , true , true ) ;
743+ }
695744 #endregion
696745 }
697746}
0 commit comments