1+ // ------------------------------------------------------------------------------------------------- 
2+ // <copyright file="HtmlReportGeneratorTestFixture.cs" company="Starion Group S.A."> 
3+ //  
4+ //   Copyright 2022-2025 Starion Group S.A. 
5+ //  
6+ //   Licensed under the Apache License, Version 2.0 (the "License"); 
7+ //   you may not use this file except in compliance with the License. 
8+ //   You may obtain a copy of the License at 
9+ //  
10+ //        http://www.apache.org/licenses/LICENSE-2.0 
11+ //  
12+ //    Unless required by applicable law or agreed to in writing, software 
13+ //    distributed under the License is distributed on an "AS IS" BASIS, 
14+ //    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
15+ //    See the License for the specific language governing permissions and 
16+ //    limitations under the License. 
17+ //  
18+ // </copyright> 
19+ // ------------------------------------------------------------------------------------------------ 
20+ 
21+ namespace  SysML2 . NET . CodeGenerator . Tests . Generators 
22+ { 
23+     using  System . Collections . Generic ; 
24+     using  System . IO ; 
25+ 
26+     using  Microsoft . Extensions . Logging ; 
27+     
28+     using  NUnit . Framework ; 
29+ 
30+     using  Serilog ; 
31+ 
32+     using  uml4net . Reporting . Drawing ; 
33+     using  uml4net . Reporting . Generators ; 
34+     using  uml4net . xmi ; 
35+     using  uml4net . xmi . Readers ; 
36+ 
37+     public  class  HtmlReportGeneratorTestFixture 
38+     { 
39+         private  FileInfo  modelFileInfo ; 
40+ 
41+         private  FileInfo  outputFileInfo ; 
42+ 
43+         private  DirectoryInfo  rootDirectoryInfo ; 
44+ 
45+         private  HtmlReportGenerator  htmlReportGenerator ; 
46+ 
47+         private  ILoggerFactory  loggerFactory ; 
48+ 
49+         private  Dictionary < string ,  string >  pathMaps ; 
50+ 
51+         private  string  rootDirectory ; 
52+ 
53+         [ OneTimeSetUp ] 
54+         public  void  OneTimeSetUp ( ) 
55+         { 
56+             Log . Logger  =  new  LoggerConfiguration ( ) 
57+                 . MinimumLevel . Debug ( ) 
58+                 . WriteTo . Console ( ) 
59+                 . CreateLogger ( ) ; 
60+ 
61+             this . loggerFactory  =  LoggerFactory . Create ( builder =>  {  builder . AddSerilog ( ) ;  } ) ; 
62+         } 
63+ 
64+         [ SetUp ] 
65+         public  void  SetUp ( ) 
66+         { 
67+             this . rootDirectory  =  Path . Combine ( TestContext . CurrentContext . TestDirectory ,  "datamodel" ) ; 
68+ 
69+             this . rootDirectoryInfo  =  new  DirectoryInfo ( this . rootDirectory ) ; 
70+ 
71+             this . pathMaps  =  new  Dictionary < string ,  string > 
72+             { 
73+                 [ "pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml" ]  = 
74+                     Path . Combine ( this . rootDirectory ,  "PrimitiveTypes.xmi" ) 
75+             } ; 
76+ 
77+             this . modelFileInfo  =  new  FileInfo ( Path . Combine ( TestContext . CurrentContext . TestDirectory ,  "datamodel" , 
78+                 "SysML_xmi.uml" ) ) ; 
79+ 
80+             this . outputFileInfo  =  new  FileInfo ( Path . Combine ( TestContext . CurrentContext . TestDirectory ,  "UML" ,  "_SysML2.NET.Core.AutoGenHtmlDocs" ,  "index.html" ) ) ; 
81+ 
82+             var  inheritanceDiagramRenderer  =  new  InheritanceDiagramRenderer ( loggerFactory . CreateLogger < InheritanceDiagramRenderer > ( ) ) ; 
83+             this . htmlReportGenerator  =  new  HtmlReportGenerator ( inheritanceDiagramRenderer ,  this . loggerFactory ) ; 
84+         } 
85+ 
86+         [ Test ] 
87+         public  void  verify_HTML_docs_Are_generated ( ) 
88+         { 
89+             var  customHtml  =  """ 
90+                              <div style="text-align: center;"> 
91+                              <H1>OMG SysML® Version 2 <a href="https://github.com/Systems-Modeling/SysML-v2-Pilot-Implementation/blob/master/org.omg.sysml/model/SysML_xmi.uml" target="_blank" rel="noopener noreferrer">UML based Meta Model Documentation</a></H1> 
92+                              <H3><a href="https://github.com/Systems-Modeling/SysML-v2-Pilot-Implementation/releases/tag/2025-07" target="_blank" rel="noopener noreferrer">Release 2025-07</a></H3> 
93+                              <p class="small">Powered By <a href="https://www.stariongroup.eu" target="_blank" rel="noopener noreferrer">Starion Group</a>, 2022-2025</p> 
94+                              <div> 
95+                              """ ; 
96+ 
97+             Assert . That ( ( )  =>  this . htmlReportGenerator . GenerateReport ( this . modelFileInfo ,  this . rootDirectoryInfo ,  false ,  this . pathMaps , 
98+             this . outputFileInfo ,  customHtml ) , 
99+             Throws . Nothing ) ; 
100+         } 
101+     } 
102+ } 
0 commit comments