public void GivenThereIsOneSimpleModuleAndThisModuleRegistersOneDependency_WhenBootstrapperIsCreated_ThenDependencyIsResolvedCorrectly()
        {
            var container = new ExtendedSimpleIocContainer();
            var bootstrapper = new SimpleBootstrapper<TestRootViewModel>(container, useApplication:false);

            var testSimpleDependency = container.Resolve<ITestSimpleDependency>();
            Assert.IsNotNull(testSimpleDependency);
        }
        public void Given_WhenDependencyIsRegisteredPerLifetimeAndDependencyIsResolved_ThenResolvedDependencyIsNotNull()
        {
            var container = new ExtendedSimpleIocContainer();
            container.RegisterPerLifetime<ITestDependency, TestDependency>(() => TestLifetimeScopeProvider.Current);
            TestLifetimeScopeProvider.Current = new TestObject();
            var dependency = container.Resolve<ITestDependency>();

            Assert.IsNotNull(dependency);
        }
        public void Given_WhenDependencyIsRegisteredPerLifetimeAndDependencyIsResolvedAndLifetimeChangesAndDependencyIsResolved_ThenResolvedDependenciesAreDifferent()
        {
            var container = new ExtendedSimpleIocContainer();
            container.RegisterPerLifetime<ITestDependency, TestDependency>(() => TestLifetimeScopeProvider.Current);
            TestLifetimeScopeProvider.Current = new TestObject();
            var dependency1 = container.Resolve<ITestDependency>();
            TestLifetimeScopeProvider.Current = new TestObject();
            var dependency2 = container.Resolve<ITestDependency>();

            Assert.AreNotEqual(dependency1, dependency2);
        }
        public void GivenThereAreMultipleSameTypedDependencies_WhenDependencyIsRegisteredByHandlerAndDependencyIsRegisteredByHandler_ThenResolutionOfDependenciesCollectionIsCorrect()
        {
            var modules = new ITestModule[] { new TestModule { Name = "1" }, new TestModule { Name = "2" } };

            var container = new ExtendedSimpleIocContainer();
            container.RegisterHandler(typeof(ITestModule), null, (c) => modules[0]);
            container.RegisterHandler(typeof(ITestModule), null, (c) => modules[1]);
            var actualModules = container.GetAllInstances(typeof(ITestModule)).ToArray();

            CollectionAssert.AreEqual(modules, actualModules);
        }
 protected virtual void RegisterModuleOverrides(ExtendedSimpleIocContainer container, Func <object> lifetimeScopeAccess)
 {
     if (container.HasHandler(typeof(ILogoUiModule), Name) == false)
     {
         container.RegisterHandler(typeof(ILogoUiModule), null, c => this);
     }
     else
     {
         _rootViewModel = null;
     }
 }
 public AppBootstrapper(ExtendedSimpleIocContainer iocContainer)
     : base(iocContainer)
 {
 }
Exemple #7
0
        public App()
        {
            var container = new ExtendedSimpleIocContainer();

            new AppBootstrapper(container);
        }
 public void RegisterModule(ExtendedSimpleIocContainer container)
 {
     _iocContainer = container;
     RegisterModuleOverrides(container, null);
 }
Exemple #9
0
 public TestBootstrapper(ExtendedSimpleIocContainer iocContainer) : base(iocContainer, useApplication: false)
 {
 }