File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed
Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change 99using LibGit2Sharp . Tests . TestHelpers ;
1010using Xunit ;
1111using Xunit . Extensions ;
12+ using Moq ;
1213
1314namespace LibGit2Sharp . Tests
1415{
@@ -107,6 +108,28 @@ public void TypesInLibGit2SharpMustBeExtensibleInATestingContext()
107108 {
108109 nonTestableTypes . Add ( type , new List < string > ( ) ) ;
109110 }
111+
112+ if ( type . IsAbstract )
113+ {
114+ continue ;
115+ }
116+
117+ try
118+ {
119+ if ( type . ContainsGenericParameters )
120+ {
121+ var constructType = type . MakeGenericType ( Enumerable . Repeat ( typeof ( object ) , type . GetGenericArguments ( ) . Length ) . ToArray ( ) ) ;
122+ Activator . CreateInstance ( constructType , true ) ;
123+ }
124+ else
125+ {
126+ Activator . CreateInstance ( type , true ) ;
127+ }
128+ }
129+ catch ( Exception ex )
130+ {
131+ nonTestableTypes . Add ( type , new List < string > ( ) ) ;
132+ }
110133 }
111134
112135 if ( nonTestableTypes . Any ( ) )
@@ -246,7 +269,7 @@ public void GetEnumeratorMethodsInLibGit2SharpMustBeVirtualForTestability()
246269 var nonVirtualGetEnumeratorMethods = Assembly . GetAssembly ( typeof ( IRepository ) )
247270 . GetExportedTypes ( )
248271 . Where ( t =>
249- t . Namespace == typeof ( IRepository ) . Namespace &&
272+ t . Namespace == typeof ( IRepository ) . Namespace &&
250273 ! t . IsSealed &&
251274 ! t . IsAbstract &&
252275 t . GetInterfaces ( ) . Any ( i => i . IsAssignableFrom ( typeof ( IEnumerable < > ) ) ) )
You can’t perform that action at this time.
0 commit comments