public void ObjectNamesForTypeIncludingAncestorsPrototypesAndFactoryObjectsPreserveOrderOfRegistration()
        {
            IList <string> names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(_factory, _expectedtype, false, false);

            Assert.AreEqual(5, names.Count);
            Assert.AreEqual(new string[] { "objA", "objB", "objC", "obj2A", "obj2C" }, names);
        }
コード例 #2
0
        public void ObjectNamesForTypeIncludingAncestors()
        {
            var names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(_factory, typeof(ITestObject));

            // includes 2 TestObjects from IFactoryObjects (DummyFactory definitions)
            Assert.AreEqual(4, names.Count);
            Assert.IsTrue(names.Contains("test"));
            Assert.IsTrue(names.Contains("test3"));
            Assert.IsTrue(names.Contains("testFactory1"));
            Assert.IsTrue(names.Contains("testFactory2"));
        }
コード例 #3
0
        public void ObjectNamesForTypeIncludingAncestorsExcludesObjectsFromParentWhenLocalObjectDefined()
        {
            DefaultListableObjectFactory root = new DefaultListableObjectFactory();

            root.RegisterObjectDefinition("excludeLocalObject", new RootObjectDefinition(typeof(ArrayList)));
            DefaultListableObjectFactory child = new DefaultListableObjectFactory(root);

            child.RegisterObjectDefinition("excludeLocalObject", new RootObjectDefinition(typeof(Hashtable)));

            var names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(child, typeof(ArrayList));

            // "excludeLocalObject" matches on the parent, but not the local object definition
            Assert.AreEqual(0, names.Count);

            names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(child, typeof(ArrayList), true, true);
            // "excludeLocalObject" matches on the parent, but not the local object definition
            Assert.AreEqual(0, names.Count);
        }
コード例 #4
0
        public void ObjectNamesForTypeIncludingAncestorsPreserveOrderOfRegistration()
        {
            MockRepository mocks = new MockRepository();
            IConfigurableListableObjectFactory of       = (IConfigurableListableObjectFactory)mocks.DynamicMock(typeof(IConfigurableListableObjectFactory));
            IConfigurableListableObjectFactory ofParent = (IConfigurableListableObjectFactory)mocks.DynamicMock(typeof(IConfigurableListableObjectFactory));
            Type EXPECTEDTYPE = typeof(ITestObject);

            Expect.Call(of.GetObjectNamesForType(EXPECTEDTYPE)).Return(new string[] { "objA", "objB", "objC" });
            Expect.Call(((IHierarchicalObjectFactory)of).ParentObjectFactory).Return(ofParent);
            Expect.Call(ofParent.GetObjectNamesForType(EXPECTEDTYPE)).Return(new string[] { "obj2A", "objB", "obj2C" });

            mocks.ReplayAll();

            string[] names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(of, EXPECTEDTYPE);
            Assert.AreEqual(5, names.Length);
            Assert.AreEqual(new string[] { "objA", "objB", "objC", "obj2A", "obj2C" }, names);

            mocks.VerifyAll();
        }