public void NothingSet() { FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject(); fac.ObjectName = "foo"; Assert.Throws <ArgumentException>(() => fac.AfterPropertiesSet()); }
public void BailsWhenBothTargetTypeAndTargetObjectPropsAreSet() { FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject(); fac.TargetObject = this; fac.TargetType = GetType(); Assert.Throws <ArgumentException>(() => fac.AfterPropertiesSet()); }
public void BailsOnNonExistantField() { FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject(); fac.StaticField = "Oragon.Spring.Objects.Factory.Config.FinalFielder.Rubbish, Oragon.Spring.Core.Tests"; fac.ObjectName = "foo"; Assert.Throws <ObjectDefinitionStoreException>(() => 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 JustTargetField() { FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject(); fac.TargetField = "Space"; fac.ObjectName = "foo"; Assert.Throws <ArgumentException>(() => 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 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); }
public void StaticFieldThatAintAssemblyQualifiedShouldStillBeResolved() { FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject(); fac.StaticField = "Oragon.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 StaticFieldWithWhitespace() { FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject(); fac.StaticField = "\tOragon.Spring.Objects.Factory.Config.FinalFielder.Name, Oragon.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 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 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 OnlyUsesObjectNameForStaticFieldIfTheStaticFieldHasNotBeenSet() { FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject(); fac.ObjectName = "System.DBNull.Value"; fac.StaticField = "Oragon.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 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); }