public void RegisterFuncByTypeTest() { SimpleSecondaryExportLocator resolver = new SimpleSecondaryExportLocator(); resolver.AddResolveValue(() => new BasicService()); object returnValue = resolver.Locate(new FauxInjectionScope(), new FauxInjectionContext(), null, typeof(BasicService), null, null); Assert.NotNull(returnValue); Assert.IsType(typeof(BasicService), returnValue); }
public void InitValueTest() { SimpleSecondaryExportLocator resolver = new SimpleSecondaryExportLocator( new Dictionary<string, object> { { "BasicService", new BasicService() } }); object returnValue = resolver.Locate(new FauxInjectionScope(), new FauxInjectionContext(), "BasicService", null, null, null); Assert.NotNull(returnValue); Assert.IsType(typeof(BasicService), returnValue); }
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); }