コード例 #1
0
        public void windsor_container_is_available_as_component()
        {
            // ARRANGE
            IWindsorEngine windsorEngine = ApplicationServer.Start();

            // ACT
            var containerTakenFromWindsor = windsorEngine.GetComponent <IWindsorContainer>();

            // ASSERT
            Assert.NotNull(containerTakenFromWindsor);
            windsorEngine.Stop();
        }
コード例 #2
0
        public void windsor_engine_is_available_as_component()
        {
            // ARRANGE
            IWindsorEngine windsorEngine = ApplicationServer.Start();

            // ACT
            var engineTakenFromWindsor = windsorEngine.GetComponent <IWindsorEngine>();

            // ASSERT
            Assert.AreEqual(windsorEngine, engineTakenFromWindsor);
            windsorEngine.Stop();
        }
コード例 #3
0
        public void GetRootLibrary()
        {
            // ARRANGE
            IWindsorEngine windsorEngine = ApplicationServer.Start();
            var            librarian     = windsorEngine.GetComponent <ILibrarian>();

            // ACT
            Library rootLibrary = librarian.GetRootLibrary();

            // ASSERT
            Assert.That(rootLibrary.Equals(new SynergyCoreTestLibrary()), Is.True);
            windsorEngine.Stop();
        }
コード例 #4
0
        public void component_marked_as_transient_is_really_so()
        {
            // ARRANGE
            IWindsorEngine windsorEngine = ApplicationServer.Start();

            // ACT
            var transient1 = windsorEngine.GetComponent <ITransientComponentMock>();
            var transient2 = windsorEngine.GetComponent <ITransientComponentMock>();

            // ASSERT
            Assert.That(transient1, Is.Not.EqualTo(transient2));
            windsorEngine.Stop();
        }
コード例 #5
0
        public void components_are_singletons_by_default()
        {
            // ARRANGE
            IWindsorEngine windsorEngine = ApplicationServer.Start();

            // ACT
            var component1 = windsorEngine.GetComponent <IComponentMock>();
            var component2 = windsorEngine.GetComponent <IComponentMock>();

            // ASSERT
            Assert.That(component1, Is.Not.Null);
            Assert.That(component1, Is.EqualTo(component2));
            windsorEngine.Stop();
        }
コード例 #6
0
        public void component_marked_as_singleton_singletons__is_really_so()
        {
            // ARRANGE
            IWindsorEngine windsorEngine = ApplicationServer.Start();

            // ACT
            var component1 = windsorEngine.GetComponent <ISingletonComponentMock>();
            var component2 = windsorEngine.GetComponent <ISingletonComponentMock>();

            // ASSERT
            Assert.That(component1, Is.Not.Null);
            Assert.That(component1, Is.EqualTo(component2));
            windsorEngine.Stop();
        }
コード例 #7
0
        public void component_list_can_be_retrieved_from_windsor_engine()
        {
            // ARRANGE
            IWindsorEngine windsorEngine    = ApplicationServer.Start();
            var            componentLocator = windsorEngine.GetComponent <IComponentLocator>();

            // ACT
            IUserRepository[] components = componentLocator.GetComponents <IUserRepository>();

            // ASSERT
            Assert.NotNull(components);
            Assert.That(components, Is.Not.Empty);
            Assert.That(components.Length, Is.EqualTo(2));
            windsorEngine.Stop();
        }
コード例 #8
0
        public void can_insert_dependent_collection_of_components()
        {
            // ARRANGE
            IWindsorEngine windsorEngine = ApplicationServer.Start();

            // ACT
            var component = windsorEngine.GetComponent <IComponentMock>();

            // ASSERT
            Assert.That(component, Is.Not.Null);
            IEnumerable <IDependentComponentMock> dependencies = component.GetDependencies();

            Assert.NotNull(dependencies);
            Assert.AreEqual(1, dependencies.Count());
            windsorEngine.Stop();
        }
コード例 #9
0
        public void component_can_be_registered_using_factory_method()
        {
            // ARRANGE
            // see: https://github.com/castleproject/Windsor/blob/master/docs/registering-components-one-by-one.md
            IWindsorEngine windsorEngine = ApplicationServer.Start();

            // ACT
            var transient1 = windsorEngine.GetComponent <IComponentCreatedViaFactory>();
            var transient2 = windsorEngine.GetComponent <IComponentCreatedViaFactory>();
            var c1         = windsorEngine.GetComponent <IContainerForComponentCreatedViaFactory>();
            var c2         = windsorEngine.GetComponent <IContainerForComponentCreatedViaFactory>();

            // ASSERT
            Assert.That(transient1, Is.Not.EqualTo(transient2));
            Assert.That(c1, Is.EqualTo(c2));
            Assert.That(c1.GetComponentCreatedViaFactory(), Is.EqualTo(c2.GetComponentCreatedViaFactory()));

            windsorEngine.Stop();
        }
コード例 #10
0
        public void GetLibraries()
        {
            // ARRANGE
            IWindsorEngine windsorEngine = ApplicationServer.Start();
            var            librarian     = windsorEngine.GetComponent <ILibrarian>();

            // ACT
            Library[] libraries = librarian.GetLibraries();

            // ASSERT
            Assert.That(libraries,
                        Is.EquivalentTo(
                            new Library[]
            {
                new SynergyCoreTestLibrary(),
                new SynergyCoreSampleLibrary(),
                new SynergyCoreLibrary(),
            }));
            windsorEngine.Stop();
        }