public void OptionalParametersSetToNullIfNotRegistered() { IUnityContainer container = new UnityContainer(); OptionalConstParameterClass result = container.Resolve <OptionalConstParameterClass>(); Assert.IsNull(result.TestObject); }
public void OptionalParametersNotResolvedIfMoreSpecificTypeRegistered() { IUnityContainer container = new UnityContainer(); var input = new TestObject(); container.RegisterInstance <TestObject>(input); OptionalConstParameterClass result = container.Resolve <OptionalConstParameterClass>(); Assert.IsNull(result.TestObject); }
public void OptionalParametersResolvedIfInstanceRegistered() { IUnityContainer container = new UnityContainer(); var input = new TestObject(); container.RegisterInstance <ITestObject>(input); OptionalConstParameterClass result = container.Resolve <OptionalConstParameterClass>(); Assert.AreSame(input, result.TestObject); }
public void OptionalParametersResolvedIfInstanceRegisteredInParent() { IUnityContainer parent = new UnityContainer(); IUnityContainer child = parent.CreateChildContainer(); var input = new TestObject(); parent.RegisterInstance <ITestObject>(input); OptionalConstParameterClass result = child.Resolve <OptionalConstParameterClass>(); Assert.AreSame(input, result.TestObject); }