Example #1
0
        public void InitializeWith_Should_Call_User_ContainerInitializers_Execute_Before_Boc_Namespace()
        {
            var testableContainerInitializer      = new TestableContainerInitializer();
            var user_testableContainerInitializer = new Mock <IContainerInitializer>();

            user_testableContainerInitializer.Setup(u => u.Execute()).Callback(
                () => Assert.False(testableContainerInitializer.Executed)).Verifiable(); //i'm being called first, so the boc. namespace one should be false

            var appDomainHelper = SetupResolve <IAppDomainHelper>();

            appDomainHelper.Setup(a => a.GetTypes(It.IsAny <Func <Type, bool> >())).Returns(() => new[]
            {
                user_testableContainerInitializer.Object.GetType(),
                typeof(TestableContainerInitializer)
            });

            resolver.Setup(r => r.ResolveAll <IAppDomainHelper>()).Returns(() => new[] { appDomainHelper.Object });

            resolver.Setup(r => r.ResolveAll <IContainerInitializer>()).Returns(() => new[] { testableContainerInitializer, user_testableContainerInitializer.Object });

            IoC.InitializeWith(resolver.Object);

            Assert.True(testableContainerInitializer.Executed);
            user_testableContainerInitializer.Verify();
        }
Example #2
0
        public void InitializeWith_Should_Call_ContainerInitializers_Execute()
        {
            var appDomainHelper = SetupResolve<IAppDomainHelper>();
            appDomainHelper.Setup(a => a.GetTypes(It.IsAny<Func<Type, bool>>())).Returns(() => new[] { typeof(TestableContainerInitializer) });
            resolver.Setup(r => r.ResolveAll<IAppDomainHelper>()).Returns(() => new[] {appDomainHelper.Object});

            var testableContainerInitializer = new TestableContainerInitializer();
            resolver.Setup(r => r.ResolveAll<IContainerInitializer>()).Returns(() => new[] { testableContainerInitializer });

            IoC.InitializeWith(resolver.Object);

            Assert.True(testableContainerInitializer.Executed);
        }
Example #3
0
        public void InitializeWith_Should_Call_ContainerInitializers_Execute()
        {
            var appDomainHelper = SetupResolve <IAppDomainHelper>();

            appDomainHelper.Setup(a => a.GetTypes(It.IsAny <Func <Type, bool> >())).Returns(() => new[] { typeof(TestableContainerInitializer) });
            resolver.Setup(r => r.ResolveAll <IAppDomainHelper>()).Returns(() => new[] { appDomainHelper.Object });

            var testableContainerInitializer = new TestableContainerInitializer();

            resolver.Setup(r => r.ResolveAll <IContainerInitializer>()).Returns(() => new[] { testableContainerInitializer });

            IoC.InitializeWith(resolver.Object);

            Assert.True(testableContainerInitializer.Executed);
        }
Example #4
0
        public void InitializeWith_Should_Call_User_ContainerInitializers_Execute_Before_Boc_Namespace()
        {
            var testableContainerInitializer = new TestableContainerInitializer();
            var user_testableContainerInitializer = new Mock<IContainerInitializer>();

            user_testableContainerInitializer.Setup(u => u.Execute()).Callback(
                () => Assert.False(testableContainerInitializer.Executed)).Verifiable(); //i'm being called first, so the boc. namespace one should be false

            var appDomainHelper = SetupResolve<IAppDomainHelper>();
            appDomainHelper.Setup(a => a.GetTypes(It.IsAny<Func<Type, bool>>())).Returns(() => new[]
                                                                                                   {
                                                                                                       user_testableContainerInitializer.Object.GetType(),
                                                                                                       typeof(TestableContainerInitializer)
                                                                                                   });

            resolver.Setup(r => r.ResolveAll<IAppDomainHelper>()).Returns(() => new[] { appDomainHelper.Object });

            resolver.Setup(r => r.ResolveAll<IContainerInitializer>()).Returns(() => new[] { testableContainerInitializer, user_testableContainerInitializer.Object });

            IoC.InitializeWith(resolver.Object);

            Assert.True(testableContainerInitializer.Executed);
            user_testableContainerInitializer.Verify();
        }