public void OptionalParametersNotResolvedIfMoreSpecificTypeRegisteredWithName() { IUnityContainer container = new UnityContainer(); var input = new TestObject(); container.RegisterInstance <TestObject>("test", input); NamedOptionalConstParameterClass result = container.Resolve <NamedOptionalConstParameterClass>(); Assert.IsNull(result.TestObject); }
public void OptionalParametersResolvedIfInstanceRegisteredWithName() { IUnityContainer container = new UnityContainer(); var input = new TestObject(); container.RegisterInstance <ITestObject>("test", input); NamedOptionalConstParameterClass result = container.Resolve <NamedOptionalConstParameterClass>(); Assert.AreSame(input, result.TestObject); }
public void OptionalParametersResolvedIfInstanceRegisteredInParentWithName() { IUnityContainer parent = new UnityContainer(); IUnityContainer child = parent.CreateChildContainer(); var input = new TestObject(); parent.RegisterInstance <ITestObject>("test", input); NamedOptionalConstParameterClass result = child.Resolve <NamedOptionalConstParameterClass>(); Assert.AreSame(input, result.TestObject); }