Esempio n. 1
0
        public void AbstractParentObjects()
        {
            XmlObjectFactory parent = new XmlObjectFactory(new ReadOnlyXmlTestResource("parent.xml", GetType()));
            parent.PreInstantiateSingletons();
            Assert.IsTrue(parent.IsSingleton("inheritedTestObjectWithoutClass"));

            // abstract objects should not match
            //TODO add overloaded GetObjectOfType with 1 arg
            IDictionary tbs = parent.GetObjectsOfType(typeof(TestObject), true, true);
            Assert.AreEqual(2, tbs.Count);
            Assert.IsTrue(tbs.Contains("inheritedTestObjectPrototype"));
            Assert.IsTrue(tbs.Contains("inheritedTestObjectSingleton"));

            // non-abstract object should work, even if it serves as parent
            object o1 = parent.GetObject("inheritedTestObjectPrototype");
            Assert.IsTrue(o1 is TestObject);

            // abstract object should return IObjectInstance itself
            object o2 = parent.GetObject("inheritedTestObjectWithoutClass");
            Assert.IsTrue(o2 is IObjectDefinition);
        }