public void CanChainGenericTypesViaRegisterTypeMethod() { // Setup Container .RegisterType(typeof(ICommand <>), typeof(LoggingCommand <>), Invoke.Constructor(Resolve.Parameter(typeof(ICommand <>), "concrete"))) .RegisterType(typeof(ICommand <>), typeof(ConcreteCommand <>), "concrete"); // Act ICommand <User> cmd = Container.Resolve <ICommand <User> >(); LoggingCommand <User> logCmd = (LoggingCommand <User>)cmd; // Verify Assert.IsNotNull(logCmd.Inner); Assert.IsInstanceOfType(logCmd.Inner, typeof(ConcreteCommand <User>)); }
public void GenericPropertyIsActuallyInjected() { // Setup Container .RegisterType(typeof(ICommand <>), typeof(LoggingCommand <>), Invoke.Constructor(), Inject.Property("Inner", Resolve.Parameter(typeof(ICommand <>), "inner"))) .RegisterType(typeof(ICommand <>), typeof(ConcreteCommand <>), "inner"); // Act ICommand <Account> result = Container.Resolve <ICommand <Account> >(); // Verify LoggingCommand <Account> actualResult = (LoggingCommand <Account>)result; Assert.IsNotNull(actualResult.Inner); Assert.IsInstanceOfType(actualResult.Inner, typeof(ConcreteCommand <Account>)); }