public void OptionalDependenciesForServiceBoundTypesAreIgnoredIfNoBindingsExist() { using (var kernel = new StandardKernel()) { RequestsOptionalService parent = kernel.Get <RequestsOptionalService>(); Assert.That(parent, Is.Not.Null); Assert.That(parent.Child, Is.Null); } }
public void OptionalDependenciesForServiceBoundTypesAreResolved() { IModule module = new InlineModule(m => { m.Bind <IMock>().To <SimpleObject>(); }); using (var kernel = new StandardKernel(module)) { RequestsOptionalService parent = kernel.Get <RequestsOptionalService>(); Assert.That(parent, Is.Not.Null); Assert.That(parent.Child, Is.Not.Null); Assert.That(parent.Child, Is.InstanceOfType(typeof(SimpleObject))); } }