File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,16 @@ public void NestedClassDependencies_CorrectlyRegistered_ResolvesRoot()
8080 Assert . IsInstanceOfType ( result , typeof ( NestedClassDependencies . RootClass ) ) ;
8181 }
8282
83+ [ TestMethod ]
84+ public void NestedClassDependencies_UsingConstructorFromAnotherType_ThrowsException ( )
85+ {
86+ var container = UtilityMethods . GetContainer ( ) ;
87+ var registerOptions = container . Register < NestedClassDependencies . RootClass > ( ) ;
88+
89+ AssertHelper . ThrowsException < TinyIoCConstructorResolutionException >
90+ ( ( ) => registerOptions . UsingConstructor ( ( ) => new RootClass ( null , null ) ) ) ;
91+ }
92+
8393 [ TestMethod ]
8494 public void NestedClassDependencies_MissingService3Registration_ResolvesRootResolutionOn ( )
8595 {
Original file line number Diff line number Diff line change @@ -1203,6 +1203,9 @@ public RegisterOptions WithStrongReference()
12031203#if EXPRESSIONS
12041204 public RegisterOptions UsingConstructor < RegisterType > ( Expression < Func < RegisterType > > constructor )
12051205 {
1206+ if ( ! IsValidAssignment ( _Registration . Type , typeof ( RegisterType ) ) )
1207+ throw new TinyIoCConstructorResolutionException ( typeof ( RegisterType ) ) ;
1208+
12061209 var lambda = constructor as LambdaExpression ;
12071210 if ( lambda == null )
12081211 throw new TinyIoCConstructorResolutionException ( typeof ( RegisterType ) ) ;
You can’t perform that action at this time.
0 commit comments