public void BasicResolverTest() { DependencyInjectionContainer container = new DependencyInjectionContainer(); SimpleSecondaryExportLocator resolver = new SimpleSecondaryExportLocator(); container.AddSecondaryLocator(resolver); container.Configure(c => c.Export<ImportConstructorService>().As<IImportConstructorService>()); resolver.AddResolveValue((IBasicService)new BasicService()); IImportConstructorService constructorService = container.Locate<IImportConstructorService>(); Assert.NotNull(constructorService); }
public void ResolveValueTypeFromChildTest() { DependencyInjectionContainer container = new DependencyInjectionContainer(); SimpleSecondaryExportLocator resolver = new SimpleSecondaryExportLocator(); container.AddSecondaryLocator(resolver); container.Configure(c => c.Export<WithCtorParamClass>()); resolver.AddResolveValue(() => (IBasicService)new BasicService()); resolver.AddResolveValue("stringParam", "Hello"); resolver.AddResolveValue("intParam", 10); WithCtorParamClass paramClass = container.Locate<WithCtorParamClass>(); Assert.NotNull(paramClass); Assert.Equal("Hello", paramClass.StringParam); Assert.Equal(10, paramClass.IntParam); }