Inheritance: IFactoryObject, IInitializingObject, IObjectNameAware
Example #1
0
        public void NothingSet()
        {
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            fac.ObjectName = "foo";
            Assert.Throws <ArgumentException>(() => fac.AfterPropertiesSet());
        }
Example #2
0
        public void NothingSet()
        {
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            fac.ObjectName = "foo";
            fac.AfterPropertiesSet();
        }
Example #3
0
        public void BailsOnNonExistantField()
        {
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            fac.StaticField = "Spring.Objects.Factory.Config.FinalFielder.Rubbish, Spring.Core.Tests";
            fac.ObjectName  = "foo";
            fac.AfterPropertiesSet();
        }
Example #4
0
        public void BailsWhenBothTargetTypeAndTargetObjectPropsAreSet()
        {
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            fac.TargetObject = this;
            fac.TargetType   = GetType();
            fac.AfterPropertiesSet();
        }
Example #5
0
        public void BailsWhenStaticFieldPassedGumpfh()
        {
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            fac.StaticField = "Goob"; // no field specified
            fac.ObjectName  = "foo";
            fac.AfterPropertiesSet();
        }
Example #6
0
        public void BailsWhenBothTargetTypeAndTargetObjectPropsAreSet()
        {
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            fac.TargetObject = this;
            fac.TargetType   = GetType();
            Assert.Throws <ArgumentException>(() => fac.AfterPropertiesSet());
        }
Example #7
0
        public void JustTargetObject()
        {
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            fac.TargetObject = this;
            fac.ObjectName   = "foo";
            fac.AfterPropertiesSet();
        }
Example #8
0
        public void BailsOnNonExistantField()
        {
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            fac.StaticField = "Spring.Objects.Factory.Config.FinalFielder.Rubbish, Spring.Core.Tests";
            fac.ObjectName  = "foo";
            Assert.Throws <ObjectDefinitionStoreException>(() => fac.AfterPropertiesSet());
        }
Example #9
0
        public void BailsWhenStaticFieldPassedGumpfh()
        {
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            fac.StaticField = "Goob"; // no field specified
            fac.ObjectName  = "foo";
            Assert.Throws <ArgumentException>(() => fac.AfterPropertiesSet());
        }
Example #10
0
        public void JustTargetField()
        {
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            fac.TargetField = "Space";
            fac.ObjectName  = "foo";
            Assert.Throws <ArgumentException>(() => fac.AfterPropertiesSet());
        }
 public void StaticFieldWithWhitespace()
 {
     FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();
     fac.StaticField = "\tSpring.Objects.Factory.Config.FinalFielder.Name, Spring.Core.Tests        ";
     fac.ObjectName = "foo";
     fac.AfterPropertiesSet();
     Assert.AreEqual(typeof (string), fac.ObjectType);
     object actual = fac.GetObject();
     Assert.AreEqual(FinalFielder.Name, actual);
 }
 public void StaticFieldThatAintAssemblyQualifiedShouldStillBeResolved()
 {
     FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();
     fac.StaticField = "Spring.Objects.Factory.Config.FinalFielder.Name";
     fac.ObjectName = "foo";
     fac.AfterPropertiesSet();
     Assert.AreEqual(typeof (string), fac.ObjectType);
     object actual = fac.GetObject();
     Assert.AreEqual(FinalFielder.Name, actual);
 }
 public void StaticFieldSystemClass()
 {
     FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();
     fac.StaticField = "System.DBNull.Value";
     fac.ObjectName = "foo";
     fac.AfterPropertiesSet();
     Assert.AreEqual(typeof (DBNull), fac.ObjectType);
     object actual = fac.GetObject();
     Assert.AreEqual(DBNull.Value, actual);
 }
Example #14
0
        public void UsesObjectNameForStaticField()
        {
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            fac.ObjectName = "System.Type.Delimiter";
            fac.AfterPropertiesSet();
            Assert.AreEqual(typeof(char), fac.ObjectType);
            object actual = fac.GetObject();

            Assert.AreEqual(Type.Delimiter, actual);
        }
Example #15
0
        public void StaticFieldIsCaseINsenSiTiVE()
        {
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            fac.StaticField = "System.Type.emptytyPES, Mscorlib";
            fac.ObjectName  = "foo";
            fac.AfterPropertiesSet();
            Assert.AreEqual(typeof(Type[]), fac.ObjectType);
            Type[] actual = fac.GetObject() as Type[];
            Assert.IsNotNull(actual);
            Assert.AreEqual(Type.EmptyTypes.Length, actual.Length);
        }
Example #16
0
        public void StaticFieldViaClassAndFieldName()
        {
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            fac.TargetField = "Name";
            fac.TargetType  = typeof(FinalFielder);
            fac.ObjectName  = "foo";
            fac.AfterPropertiesSet();
            object actual = fac.GetObject();

            Assert.AreEqual(FinalFielder.Name, actual);
        }
Example #17
0
        public void OnlyUsesObjectNameForStaticFieldIfTheStaticFieldHasNotBeenSet()
        {
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            fac.ObjectName  = "System.DBNull.Value";
            fac.StaticField = "Spring.Objects.Factory.Config.FinalFielder.Name";
            fac.AfterPropertiesSet();
            Assert.AreEqual(typeof(string), fac.ObjectType);
            object actual = fac.GetObject();

            Assert.AreEqual(FinalFielder.Name, actual);
        }
Example #18
0
        public void StaticFieldWithWhitespace()
        {
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            fac.StaticField = "\tSpring.Objects.Factory.Config.FinalFielder.Name, Spring.Core.Tests        ";
            fac.ObjectName  = "foo";
            fac.AfterPropertiesSet();
            Assert.AreEqual(typeof(string), fac.ObjectType);
            object actual = fac.GetObject();

            Assert.AreEqual(FinalFielder.Name, actual);
        }
Example #19
0
        public void StaticFieldSystemClass()
        {
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            fac.StaticField = "System.DBNull.Value";
            fac.ObjectName  = "foo";
            fac.AfterPropertiesSet();
            Assert.AreEqual(typeof(DBNull), fac.ObjectType);
            object actual = fac.GetObject();

            Assert.AreEqual(DBNull.Value, actual);
        }
Example #20
0
        public void StaticFieldThatAintAssemblyQualifiedShouldStillBeResolved()
        {
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            fac.StaticField = "Spring.Objects.Factory.Config.FinalFielder.Name";
            fac.ObjectName  = "foo";
            fac.AfterPropertiesSet();
            Assert.AreEqual(typeof(string), fac.ObjectType);
            object actual = fac.GetObject();

            Assert.AreEqual(FinalFielder.Name, actual);
        }
Example #21
0
        public void InstanceField()
        {
            FinalFielder expected = new FinalFielder();

            expected.Age = 56;
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            fac.TargetObject = expected;
            fac.TargetField  = "Age";
            fac.ObjectName   = "foo";
            fac.AfterPropertiesSet();
            object actual = fac.GetObject();

            Assert.AreEqual(expected.Age, actual);
        }
 public void BailsWhenBothTargetTypeAndTargetObjectPropsAreSet()
 {
     FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();
     fac.TargetObject = this;
     fac.TargetType = GetType();
     fac.AfterPropertiesSet();
 }
 public void BailsOnNonExistantField()
 {
     FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();
     fac.StaticField = "Spring.Objects.Factory.Config.FinalFielder.Rubbish, Spring.Core.Tests";
     fac.ObjectName = "foo";
     fac.AfterPropertiesSet();
 }
 public void StaticFieldIsCaseINsenSiTiVE()
 {
     FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();
     fac.StaticField = "System.Type.emptytyPES, Mscorlib";
     fac.ObjectName = "foo";
     fac.AfterPropertiesSet();
     Assert.AreEqual(typeof (Type[]), fac.ObjectType);
     Type[] actual = fac.GetObject() as Type[];
     Assert.IsNotNull(actual);
     Assert.AreEqual(Type.EmptyTypes.Length, actual.Length);
 }
 public void BailsWhenStaticFieldPassedGumpfh()
 {
     FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();
     fac.StaticField = "Goob"; // no field specified
     fac.ObjectName = "foo";
     fac.AfterPropertiesSet();
 }
 public void JustTargetObject()
 {
     FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();
     fac.TargetObject = this;
     fac.ObjectName = "foo";
     fac.AfterPropertiesSet();
 }
 public void UsesObjectNameForStaticField()
 {
     FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();
     fac.ObjectName = "System.Type.Delimiter";
     fac.AfterPropertiesSet();
     Assert.AreEqual(typeof (char), fac.ObjectType);
     object actual = fac.GetObject();
     Assert.AreEqual(Type.Delimiter, actual);
 }
 public void InstanceField()
 {
     FinalFielder expected = new FinalFielder();
     expected.Age = 56;
     FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();
     fac.TargetObject = expected;
     fac.TargetField = "Age";
     fac.ObjectName = "foo";
     fac.AfterPropertiesSet();
     object actual = fac.GetObject();
     Assert.AreEqual(expected.Age, actual);
 }
 public void IsSingleton()
 {
     FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();
     Assert.IsTrue(fac.IsSingleton);
 }
 public void StaticFieldViaClassAndFieldName()
 {
     FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();
     fac.TargetField = "Name";
     fac.TargetType = typeof (FinalFielder);
     fac.ObjectName = "foo";
     fac.AfterPropertiesSet();
     object actual = fac.GetObject();
     Assert.AreEqual(FinalFielder.Name, actual);
 }
 public void BailsOnNonExistantField()
 {
     FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();
     fac.StaticField = "Spring.Objects.Factory.Config.FinalFielder.Rubbish, Spring.Core.Tests";
     fac.ObjectName = "foo";
     Assert.Throws<ObjectDefinitionStoreException>(() => fac.AfterPropertiesSet());
 }
Example #32
0
        public void IsSingleton()
        {
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            Assert.IsTrue(fac.IsSingleton);
        }
 public void NothingSet()
 {
     FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();
     fac.ObjectName = "foo";
     fac.AfterPropertiesSet();
 }
 public void BailsWhenBothTargetTypeAndTargetObjectPropsAreSet()
 {
     FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();
     fac.TargetObject = this;
     fac.TargetType = GetType();
     Assert.Throws<ArgumentException>(() => fac.AfterPropertiesSet());
 }
 public void BailsWhenStaticFieldPassedGumpfh()
 {
     FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();
     fac.StaticField = "Goob"; // no field specified
     fac.ObjectName = "foo";
     Assert.Throws<ArgumentException>(() => fac.AfterPropertiesSet());
 }
 public void OnlyUsesObjectNameForStaticFieldIfTheStaticFieldHasNotBeenSet()
 {
     FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();
     fac.ObjectName = "System.DBNull.Value";
     fac.StaticField = "Spring.Objects.Factory.Config.FinalFielder.Name";
     fac.AfterPropertiesSet();
     Assert.AreEqual(typeof (string), fac.ObjectType);
     object actual = fac.GetObject();
     Assert.AreEqual(FinalFielder.Name, actual);
 }
 public void JustTargetObject()
 {
     FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();
     fac.TargetObject = this;
     fac.ObjectName = "foo";
     Assert.Throws<ArgumentException>(() => fac.AfterPropertiesSet());
 }