Exemplo n.º 1
0
        public void ContainerCallsExtensionsInitializeMethod()
        {
            MockContainerExtension extension = new MockContainerExtension();
            IUnityContainer        container = new UnityContainer();

            container.AddExtension(extension);

            Assert.True(extension.InitializeWasCalled);
        }
Exemplo n.º 2
0
        public void ExtensionReceivesExtensionContextInInitialize()
        {
            MockContainerExtension extension = new MockContainerExtension();
            IUnityContainer        container = new UnityContainer();

            container.AddExtension(extension);

            Assert.NotNull(extension.Context);
            Assert.Same(container, extension.Context.Container);
        }
Exemplo n.º 3
0
        public void CanLookupExtensionByClassName()
        {
            MockContainerExtension extension = new MockContainerExtension();
            IUnityContainer container = new UnityContainer();
            container.AddExtension(extension);

            MockContainerExtension result = container.Configure<MockContainerExtension>();

            Assert.Same(extension, result);
        }
Exemplo n.º 4
0
        public void Ext_CanGetConfigurationWithoutGenericMethod()
        {
            MockContainerExtension extension = new MockContainerExtension();
            IUnityContainer        container = new UnityContainer()
                                               .AddExtension(extension);
            IMockConfiguration config = (IMockConfiguration)container.Configure(typeof(IMockConfiguration));

            Assert.AreSame(extension, config);
            Assert.AreSame(container, config.Container);
        }
Exemplo n.º 5
0
        public void Ext_CanGetConfigurationInterfaceFromExtension()
        {
            MockContainerExtension extension = new MockContainerExtension();
            IUnityContainer        container = new UnityContainer()
                                               .AddExtension(extension);
            IMockConfiguration config = container.Configure <IMockConfiguration>();

            Assert.AreSame(extension, config);
            Assert.AreSame(container, config.Container);
        }
Exemplo n.º 6
0
        public void CanLookupExtensionByClassName()
        {
            MockContainerExtension extension = new MockContainerExtension();
            IUnityContainer        container = new UnityContainer();

            container.AddExtension(extension);

            MockContainerExtension result = container.Configure <MockContainerExtension>();

            Assert.Same(extension, result);
        }
Exemplo n.º 7
0
        public void CanGetConfigurationWithoutGenericMethod()
        {
            MockContainerExtension extension = new MockContainerExtension();
            IUnityContainer container = new UnityContainer()
                .AddExtension(extension);

            IMockConfiguration config = (IMockConfiguration)container.Configure(typeof(IMockConfiguration));

            Assert.Same(extension, config);
            Assert.Same(container, config.Container);
        }
Exemplo n.º 8
0
        public void CanGetConfigurationInterfaceFromExtension()
        {
            MockContainerExtension extension = new MockContainerExtension();
            IUnityContainer container = new UnityContainer()
                .AddExtension(extension);

            IMockConfiguration config = container.Configure<IMockConfiguration>();

            Assert.Same(extension, config);
            Assert.Same(container, config.Container);
        }
Exemplo n.º 9
0
        public void FactoryOnlySetsContainerOnce()
        {
            Prism.Ioc.ContainerLocator.ResetContainer();
            var container  = new MockContainerExtension();
            var container2 = new Mock2ContainerExtension();

            Prism.Ioc.ContainerLocator.SetContainerExtension(() => container);
            Assert.Same(container, Prism.Ioc.ContainerLocator.Container);

            Prism.Ioc.ContainerLocator.SetContainerExtension(() => container2);
            Assert.IsNotType <Mock2ContainerExtension>(Prism.Ioc.ContainerLocator.Container);
            Assert.Same(container, Prism.Ioc.ContainerLocator.Container);
        }
Exemplo n.º 10
0
        public void ChildContainerCreatedEventGivesChildContainerToExtension()
        {
            var mockExtension             = new MockContainerExtension();
            ExtensionContext childContext = null;

            var container = new UnityContainer()
                            .AddExtension(mockExtension);

            mockExtension.Context.ChildContainerCreated += (sender, ev) =>
            {
                childContext = ev.ChildContext;
            };

            var child = container.CreateChildContainer();

            Assert.Same(child, childContext.Container);
        }
Exemplo n.º 11
0
        public void ContainerRaisesChildContainerCreatedToExtension()
        {
            bool childContainerEventRaised = false;
            var  mockExtension             = new MockContainerExtension();

            var container = new UnityContainer()
                            .AddExtension(mockExtension);

            mockExtension.Context.ChildContainerCreated += (sender, ev) =>
            {
                childContainerEventRaised = true;
            };

            var child = container.CreateChildContainer();

            Assert.True(childContainerEventRaised);
        }
Exemplo n.º 12
0
        public void ChildContainerCreatedEventGivesChildContainerToExtension()
        {
            var mockExtension = new MockContainerExtension();
            ExtensionContext childContext = null;

            var container = new UnityContainer()
                .AddExtension(mockExtension);

            mockExtension.Context.ChildContainerCreated += (sender, ev) =>
            {
                childContext = ev.ChildContext;
            };

            var child = container.CreateChildContainer();
            Assert.Same(child, childContext.Container);
        }
Exemplo n.º 13
0
        public void ExtensionReceivesExtensionContextInInitialize()
        {
            MockContainerExtension extension = new MockContainerExtension();
            IUnityContainer container = new UnityContainer();
            container.AddExtension(extension);

            Assert.NotNull(extension.Context);
            Assert.Same(container, extension.Context.Container);
        }
Exemplo n.º 14
0
        public void ContainerRaisesChildContainerCreatedToExtension()
        {
            bool childContainerEventRaised = false;
            var mockExtension = new MockContainerExtension();

            var container = new UnityContainer()
                .AddExtension(mockExtension);

            mockExtension.Context.ChildContainerCreated += (sender, ev) =>
                {
                    childContainerEventRaised = true;
                };

            var child = container.CreateChildContainer();
            Assert.True(childContainerEventRaised);
        }
Exemplo n.º 15
0
        public void ContainerCallsExtensionsInitializeMethod()
        {
            MockContainerExtension extension = new MockContainerExtension();
            IUnityContainer container = new UnityContainer();
            container.AddExtension(extension);

            Assert.True(extension.InitializeWasCalled);
        }