public void ObjectNamesIncludingAncestorsPreserveOrderOfRegistration()
        {
            MockRepository mocks = new MockRepository();
            IConfigurableListableObjectFactory of       = (IConfigurableListableObjectFactory)mocks.DynamicMock(typeof(IConfigurableListableObjectFactory));
            IConfigurableListableObjectFactory ofParent = (IConfigurableListableObjectFactory)mocks.DynamicMock(typeof(IConfigurableListableObjectFactory));

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

            mocks.ReplayAll();

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

            mocks.VerifyAll();
        }
Esempio n. 2
0
        public void ObjectNamesForTypeIncludingAncestorsPrototypesAndFactoryObjectsPreserveOrderOfRegistration()
        {
            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, false, false)).Return(new string[] { "objA", "objB", "objC" });
            Expect.Call(((IHierarchicalObjectFactory)of).ParentObjectFactory).Return(ofParent);
            Expect.Call(ofParent.GetObjectNamesForType(EXPECTEDTYPE, false, false)).Return(new string[] { "obj2A", "objB", "obj2C" });

            mocks.ReplayAll();

            IList <string> names = ObjectFactoryUtils.ObjectNamesForTypeIncludingAncestors(of, EXPECTEDTYPE, false, false);

            Assert.AreEqual(5, names.Count);
            Assert.AreEqual(new string[] { "objA", "objB", "objC", "obj2A", "obj2C" }, names);


            mocks.VerifyAll();
        }