@@ -9,11 +9,13 @@ public class LazyProxyBuilderTests
9
9
{
10
10
public interface IBaseArgument { }
11
11
12
- public abstract class BaseArgument : IBaseArgument { }
12
+ public interface IOtherBaseArgument { }
13
+
14
+ public abstract class BaseArgument : IBaseArgument , IOtherBaseArgument { }
13
15
14
16
public abstract class BaseArgument2 { }
15
17
16
- public struct TestArgument : IBaseArgument { }
18
+ public struct TestArgument : IBaseArgument , IOtherBaseArgument { }
17
19
18
20
// ReSharper disable once MemberCanBePrivate.Global
19
21
public class TestArgument2 : BaseArgument { }
@@ -44,6 +46,10 @@ public interface ITestService : IParentTestService
44
46
string MethodWithDefaultValue ( string arg = "arg" ) ;
45
47
string MethodWithOutValue ( out string arg ) ;
46
48
string MethodWithRefValue ( ref TestArgument arg ) ;
49
+
50
+ void GenericMethod < T > ( )
51
+ where T : IBaseArgument , IOtherBaseArgument { }
52
+
47
53
string GenericMethod < T1 , T2 , T3 > ( string arg )
48
54
where T1 : class , IBaseArgument , new ( )
49
55
where T2 : struct
@@ -52,7 +58,7 @@ string GenericMethod<T1, T2, T3>(string arg)
52
58
53
59
// ReSharper disable once MemberCanBePrivate.Global
54
60
public interface IGenericTestService < T , in TIn , out TOut >
55
- where T : class , IBaseArgument , new ( )
61
+ where T : class , IBaseArgument , IOtherBaseArgument , new ( )
56
62
where TIn : struct
57
63
where TOut : BaseArgument2 , IBaseArgument
58
64
{
@@ -76,7 +82,7 @@ public void ProxyMustImplementInterface()
76
82
public void ExceptionMustBeThrownForBuildingProxyByClass ( )
77
83
{
78
84
Assert . Throws < NotSupportedException > (
79
- ( ) => LazyProxyBuilder . GetType < AbstractTestService > ( ) ) ;
85
+ LazyProxyBuilder . GetType < AbstractTestService > ) ;
80
86
}
81
87
82
88
[ Fact ]
@@ -402,10 +408,16 @@ public void GenericInterfaceWithDifferentTypeParametersMustBeCreatedWithoutExcep
402
408
LazyProxyBuilder . GetType ( typeof ( IGenericTestService < , , > ) ) ;
403
409
LazyProxyBuilder . GetType < IGenericTestService < TestArgument2 , TestArgument , TestArgument4 > > ( ) ;
404
410
LazyProxyBuilder . GetType < IGenericTestService < TestArgument3 , TestArgument , TestArgument4 > > ( ) ;
405
-
406
411
} ) ;
407
412
408
413
Assert . Null ( exception ) ;
409
414
}
415
+
416
+ [ Fact ]
417
+ public void GenericMethodWithMultipleInterfaceConstraintsMustBeProxied ( )
418
+ {
419
+ var proxy = LazyProxyBuilder . CreateInstance ( Mock . Of < ITestService > ) ;
420
+ proxy . GenericMethod < TestArgument > ( ) ;
421
+ }
410
422
}
411
- }
423
+ }
0 commit comments