1+ using NUnit . Framework ;
2+ using PCTTools . Sample . SAssemblyCatalog . Misc ;
3+
4+ namespace PCTTools . Tests . TAssemblyCatalog
5+ {
6+
7+ [ TestFixture ( ) ]
8+ public class BaseTypeTests
9+ {
10+ [ Test ( ) ]
11+ public void InterfaceBaseTypesTest ( )
12+ {
13+ var pct = new AssemblyCatalog ( ) ;
14+
15+ pct . GenerateDocumentationFromAssembly ( typeof ( IParentInterface ) . Assembly ) ;
16+ Assert . That ( pct . HasError , Is . False ) ;
17+
18+ var childMultiParentInterface = pct . TypeDocumentations . First ( x => x . IsInterface && x . ShortName == nameof ( IChildMultiParentInterface ) ) ;
19+ Assert . That ( childMultiParentInterface . BaseTypes . Count , Is . EqualTo ( 2 ) , $ "{ nameof ( IChildMultiParentInterface ) } should have 2 parents") ;
20+ Assert . That ( childMultiParentInterface . BaseTypes , Does . Contain ( typeof ( IParentInterface ) . FullName ) ) ;
21+ Assert . That ( childMultiParentInterface . BaseTypes , Does . Contain ( typeof ( IParentBInterface ) . FullName ) ) ;
22+
23+ var childParentInterface = pct . TypeDocumentations . First ( x => x . IsInterface && x . ShortName == nameof ( IChildInterface ) ) ;
24+ Assert . That ( childParentInterface . BaseTypes . Count , Is . EqualTo ( 1 ) , $ "{ nameof ( IChildInterface ) } should have 1 parent") ;
25+ Assert . That ( childParentInterface . BaseTypes , Does . Contain ( typeof ( IParentInterface ) . FullName ) ) ;
26+
27+ var doctype = pct . TypeDocumentations . First ( t => t . Name . Equals (
28+ typeof ( IParentInterface ) . FullName ) ) ;
29+
30+ Assert . That ( doctype . IsInterface , Is . EqualTo ( true ) , "IParentInterface should be an interface" ) ;
31+ Assert . That ( doctype . BaseTypes , Is . Not . Null , "BaseTypes should not be null" ) ;
32+ Assert . That ( doctype . BaseTypes , Is . Empty , "An interface with no parent should have no BaseTypes" ) ;
33+
34+ doctype = pct . TypeDocumentations . First ( t => t . Name . Equals (
35+ typeof ( IChildInterface ) . FullName ) ) ;
36+
37+ Assert . That ( doctype . IsInterface , Is . EqualTo ( true ) , "IChildInterface should be an interface" ) ;
38+ Assert . That ( doctype . BaseTypes , Is . Not . Null , "BaseTypes should not be null" ) ;
39+ }
40+ }
41+ }
0 commit comments