public void cannot_resolve_concrete_types_not_registered() { var sut = new IocContainer(); sut.CanResolve <ConcreteObjectWithOneConcreteConstructor>().ShouldBe(false); sut.CanResolve <Dependency1>().ShouldBe(false); }
public void can_register_service_implementation() { var sut = new IocContainer(); sut.Register <IDependency1, Dependency1>(); sut.CanResolve <IDependency1>().ShouldBe(true); }
/// <summary> /// Loads the current module. /// </summary> protected override bool LoadInternal() { //NOTE: You can use the custom extension methods in bindings. BindingServiceProvider .ResourceResolver .AddType(typeof(CustomExtensionMethods).Name, typeof(CustomExtensionMethods)); if (Mode == LoadMode.Design) { var localizationManager = new LocalizationManager(); if (IocContainer != null) { IocContainer.BindToConstant <ILocalizationManager>(localizationManager); } } else { if (!IocContainer.CanResolve <ILocalizationManager>()) { IocContainer.Bind <ILocalizationManager, LocalizationManager>(DependencyLifecycle.SingleInstance); } } if (IocContainer != null) { IocContainer.Bind <IResourceMonitor, ResourceMonitor>(DependencyLifecycle.SingleInstance); } return(true); }
/// <summary> /// Initializes the current bootstraper. /// </summary> protected virtual void OnInitialize() { LoadModules(); IViewModelSettings settings = CreateViewModelSettings(); if (!IocContainer.CanResolve <IViewModelSettings>()) { IocContainer.BindToConstant(settings); } ServiceProvider.Initialize(IocContainer, Platform); }
/// <summary> /// Initializes the current unit-test. /// </summary> protected void Initialize([NotNull] IIocContainer iocContainer, PlatformInfo platform, params IModule[] modules) { Should.NotBeNull(iocContainer, "iocContainer"); ServiceProvider.DesignTimeManager = new DesignTimeManagerImpl(platform); if (modules != null) { CreateModuleContext(iocContainer).LoadModules(modules); } _iocContainer = iocContainer; if (ViewModelProvider == null) { ViewModelProvider = IocContainer.CanResolve <IViewModelProvider>() ? IocContainer.Get <IViewModelProvider>() : new ViewModelProvider(IocContainer); } ServiceProvider.Initialize(iocContainer, platform ?? PlatformInfo.UnitTest); }
public bool CanResolve <T>() where T : class { return(_container.CanResolve <T>()); }
public void cannot_resolve_service_implementations_that_are_not_registered() { var sut = new IocContainer(); sut.CanResolve <ConcreteObjectWithOneInterfaceConstructor>().ShouldBe(false); }
public bool CanResolve(Type service, string name = null) { return(IocContainer.CanResolve(service, name)); }
public bool CanResolve <TType>() where TType : class { return(_baseContainer.CanResolve <TType>()); }
// enumerate public bool HasRegistered <TService>() { return(_container.CanResolve(null, typeof(TService))); }