Simple object used to check dependency checking.
        public void AssignObjectNames()
        {
            string className = typeof (DependenciesObject).FullName;

            string targetName = className + ObjectDefinitionReaderUtils.GENERATED_OBJECT_NAME_SEPARATOR + "0";
            DependenciesObject topLevel1 = (DependenciesObject) objectFactory.GetObject(targetName);
            Assert.IsNotNull(topLevel1);

            targetName = className + ObjectDefinitionReaderUtils.GENERATED_OBJECT_NAME_SEPARATOR + "1";
            DependenciesObject topLevel2 = (DependenciesObject)objectFactory.GetObject(targetName);
            Assert.IsNotNull(topLevel1);

            targetName = className + ObjectDefinitionReaderUtils.GENERATED_OBJECT_NAME_SEPARATOR + "2";
            DependenciesObject topLevel3 = (DependenciesObject)objectFactory.GetObject(targetName);
            Assert.IsNotNull(topLevel1);


            string childClassName = typeof(TestObject).FullName;
            TestObject child1 = (TestObject) topLevel1.Spouse;
            Assert.IsNotNull(child1);
            Assert.IsTrue(child1.ObjectName.IndexOf(childClassName) != -1);

            TestObject child2 = (TestObject)topLevel2.Spouse;
            Assert.IsNotNull(child2);
            Assert.IsTrue(child2.ObjectName.IndexOf(childClassName) != -1);

            TestObject child3 = (TestObject)topLevel3.Spouse;
            Assert.IsNotNull(child3);
            Assert.IsTrue(child3.ObjectName.IndexOf(childClassName) != -1);

            Assert.AreNotEqual(child1.ObjectName, child2.ObjectName);
        }
 public void AutowireExistingObjectByTypeWithNoDependencyCheck()
 {
     DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
     DependenciesObject existingObj = new DependenciesObject();
     lof.AutowireObjectProperties(existingObj, AutoWiringMode.ByType, false);
     Assert.IsNull(existingObj.Spouse);
 }
 public void AutowireExistingObjectByTypeWithDependencyCheck()
 {
     DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
     DependenciesObject existingObj = new DependenciesObject();
     lof.AutowireObjectProperties(existingObj, AutoWiringMode.ByType, true);
 }
 public void AutowireByTypeWithInvalidAutowireMode()
 {
     DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
     DependenciesObject obj = new DependenciesObject();
     lof.AutowireObjectProperties(obj, AutoWiringMode.Constructor, true);
 }
 public void AutowireExistingObjectByType()
 {
     DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
     RootObjectDefinition rod = new RootObjectDefinition(typeof(TestObject));
     lof.RegisterObjectDefinition("test", rod);
     DependenciesObject existingObj = new DependenciesObject();
     lof.AutowireObjectProperties(existingObj, AutoWiringMode.ByType, true);
     TestObject test = (TestObject)lof.GetObject("test");
     Assert.AreEqual(existingObj.Spouse, test);
 }
 public void AutowireExistingObjectByNameWithNoDependencyCheck()
 {
     DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
     RootObjectDefinition rod = new RootObjectDefinition(typeof(TestObject));
     lof.RegisterObjectDefinition("Spous", rod);
     DependenciesObject existingObj = new DependenciesObject();
     lof.AutowireObjectProperties(existingObj, AutoWiringMode.ByName, false);
     Assert.IsNull(existingObj.Spouse);
 }
 public void AutowireExistingObjectByNameWithDependencyCheck()
 {
     DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
     RootObjectDefinition rod = new RootObjectDefinition(typeof(TestObject));
     lof.RegisterObjectDefinition("Spous", rod);
     DependenciesObject existingObj = new DependenciesObject();
     lof.AutowireObjectProperties(existingObj, AutoWiringMode.ByName, true);
     Assert.Fail("Should have thrown UnsatisfiedDependencyException");
 }
 public void AutowireExistingObjectByName()
 {
     DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
     RootObjectDefinition rod = new RootObjectDefinition(typeof(TestObject));
     lof.RegisterObjectDefinition("Spouse", rod);
     DependenciesObject existingObj = new DependenciesObject();
     lof.AutowireObjectProperties(existingObj, AutoWiringMode.ByName, true);
     TestObject spouse = (TestObject)lof.GetObject("Spouse");
     Assert.AreEqual(existingObj.Spouse, spouse);
     Assert.IsTrue(ObjectFactoryUtils.ObjectOfType(lof, typeof(TestObject)) == spouse);
 }
 public void AutowireExistingObjectByTypeWithDependencyCheck()
 {
     DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
     DependenciesObject existingObj = new DependenciesObject();
     Assert.Throws<UnsatisfiedDependencyException>(() => lof.AutowireObjectProperties(existingObj, AutoWiringMode.ByType, true));
 }
 public void AutowireByTypeWithInvalidAutowireMode()
 {
     DefaultListableObjectFactory lof = new DefaultListableObjectFactory();
     DependenciesObject obj = new DependenciesObject();
     Assert.Throws<ArgumentException>(() => lof.AutowireObjectProperties(obj, AutoWiringMode.Constructor, true));
 }