@@ -575,6 +575,115 @@ public void TestIssue5()
575575 Assert . Contains ( "<w:hyperlink w:tgtFrame=\" _blank\" " , xml ) ;
576576 }
577577
578+ [ Fact ]
579+ public void MiniWordHyperLink_List ( )
580+ {
581+ var path = PathHelper . GetTempFilePath ( ) ;
582+ var templatePath = PathHelper . GetFile ( "TestBasicFill.docx" ) ;
583+ var value = new Dictionary < string , object > ( )
584+ {
585+ [ "Name" ] = new List < MiniWordHyperLink > ( ) {
586+ new MiniWordHyperLink ( ) {
587+ Url = "https://google.com" ,
588+ Text = "測試連結22!!"
589+ } ,
590+ new MiniWordHyperLink ( ) {
591+ Url = "https://google1.com" ,
592+ Text = "測試連結11!!"
593+ }
594+ } ,
595+ [ "Company_Name" ] = "MiniSofteware" ,
596+ [ "CreateDate" ] = new DateTime ( 2021 , 01 , 01 ) ,
597+ [ "VIP" ] = true ,
598+ [ "Points" ] = 123 ,
599+ [ "APP" ] = "Demo APP" ,
600+ } ;
601+ MiniWord . SaveAsByTemplate ( path , templatePath , value ) ;
602+ //Console.WriteLine(path);
603+ var docXml = Helpers . GetZipFileContent ( path , "word/document.xml" ) ;
604+ Assert . DoesNotContain ( "Jack Demo APP Account Data" , docXml ) ;
605+ Assert . Contains ( "MiniSofteware Demo APP Account Data" , docXml ) ;
606+ Assert . Contains ( "MiniSofteware Demo APP Account Data" , docXml ) ;
607+ Assert . Contains ( "<w:hyperlink w:tgtFrame=\" _blank\" " , docXml ) ;
608+
609+ var relsXml = Helpers . GetZipFileContent ( path , "word/_rels/document.xml.rels" ) ;
610+ Assert . Contains ( "<Relationship Type=\" http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\" Target=\" https://google.com\" " , relsXml ) ;
611+ Assert . Contains ( "<Relationship Type=\" http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\" Target=\" https://google1.com\" " , relsXml ) ;
612+ }
613+
614+
615+ [ Fact ]
616+ public void MiniWordHyperLink_Array ( )
617+ {
618+ var path = PathHelper . GetTempFilePath ( ) ;
619+ var templatePath = PathHelper . GetFile ( "TestBasicFill.docx" ) ;
620+ var value = new Dictionary < string , object > ( )
621+ {
622+ [ "Name" ] = new MiniWordHyperLink [ ] {
623+ new MiniWordHyperLink ( ) {
624+ Url = "https://google.com" ,
625+ Text = "測試連結22!!"
626+ } ,
627+ new MiniWordHyperLink ( ) {
628+ Url = "https://google1.com" ,
629+ Text = "測試連結11!!"
630+ }
631+ } ,
632+ [ "Company_Name" ] = "MiniSofteware" ,
633+ [ "CreateDate" ] = new DateTime ( 2021 , 01 , 01 ) ,
634+ [ "VIP" ] = true ,
635+ [ "Points" ] = 123 ,
636+ [ "APP" ] = "Demo APP" ,
637+ } ;
638+ MiniWord . SaveAsByTemplate ( path , templatePath , value ) ;
639+
640+ var docXml = Helpers . GetZipFileContent ( path , "word/document.xml" ) ;
641+ Assert . DoesNotContain ( "Jack Demo APP Account Data" , docXml ) ;
642+ Assert . Contains ( "MiniSofteware Demo APP Account Data" , docXml ) ;
643+ Assert . Contains ( "MiniSofteware Demo APP Account Data" , docXml ) ;
644+ Assert . Contains ( "<w:hyperlink w:tgtFrame=\" _blank\" " , docXml ) ;
645+
646+ var relsXml = Helpers . GetZipFileContent ( path , "word/_rels/document.xml.rels" ) ;
647+ Assert . Contains ( "<Relationship Type=\" http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\" Target=\" https://google.com\" " , relsXml ) ;
648+ Assert . Contains ( "<Relationship Type=\" http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\" Target=\" https://google1.com\" " , relsXml ) ;
649+ }
650+
651+ [ Fact ]
652+ public void MiniWordHyperLink_AnonymousArray ( )
653+ {
654+ var path = PathHelper . GetTempFilePath ( ) ;
655+ var templatePath = PathHelper . GetFile ( "TestBasicFill.docx" ) ;
656+ var value = new Dictionary < string , object > ( )
657+ {
658+ [ "Name" ] = new [ ] {
659+ new MiniWordHyperLink ( ) {
660+ Url = "https://google.com" ,
661+ Text = "測試連結22!!"
662+ } ,
663+ new MiniWordHyperLink ( ) {
664+ Url = "https://google1.com" ,
665+ Text = "測試連結11!!"
666+ }
667+ } ,
668+ [ "Company_Name" ] = "MiniSofteware" ,
669+ [ "CreateDate" ] = new DateTime ( 2021 , 01 , 01 ) ,
670+ [ "VIP" ] = true ,
671+ [ "Points" ] = 123 ,
672+ [ "APP" ] = "Demo APP" ,
673+ } ;
674+ MiniWord . SaveAsByTemplate ( path , templatePath , value ) ;
675+
676+ var docXml = Helpers . GetZipFileContent ( path , "word/document.xml" ) ;
677+ Assert . DoesNotContain ( "Jack Demo APP Account Data" , docXml ) ;
678+ Assert . Contains ( "MiniSofteware Demo APP Account Data" , docXml ) ;
679+ Assert . Contains ( "MiniSofteware Demo APP Account Data" , docXml ) ;
680+ Assert . Contains ( "<w:hyperlink w:tgtFrame=\" _blank\" " , docXml ) ;
681+
682+ var relsXml = Helpers . GetZipFileContent ( path , "word/_rels/document.xml.rels" ) ;
683+ Assert . Contains ( "<Relationship Type=\" http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\" Target=\" https://google.com\" " , relsXml ) ;
684+ Assert . Contains ( "<Relationship Type=\" http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\" Target=\" https://google1.com\" " , relsXml ) ;
685+ }
686+
578687 /// <summary>
579688 /// [Fuzzy Regex replace similar key · Issue #5 · mini-software/MiniWord](https://github.com/mini-software/MiniWord/issues/5)
580689 /// </summary>
0 commit comments