public void BailsWhenJustTargetTypeIsSet() { PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); fac.TargetType = GetType(); Assert.Throws <ArgumentException>(() => fac.AfterPropertiesSet()); }
public void BailsWhenJustTargetObjectIsSet() { PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); fac.TargetObject = this; Assert.Throws <ArgumentException>(() => fac.AfterPropertiesSet(), "The TargetProperty property is required."); }
public void ResistsSettingTheArgumentsToNull() { PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); fac.Arguments = null; Assert.IsNotNull(fac.Arguments); }
public void BailsOnNonExistantProperty() { PropertyObject expected = new PropertyObject(); PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); fac.TargetObject = expected; fac.TargetProperty = "Blister"; Assert.Throws <InvalidPropertyException>(() => fac.AfterPropertiesSet()); }
public void BailsOnWriteOnlyProperty() { PropertyObject expected = new PropertyObject(); PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); fac.TargetObject = expected; fac.TargetProperty = "Greenness"; Assert.Throws <NotWritablePropertyException>(() => fac.AfterPropertiesSet()); }
public void BailsWhenReadingIndexedPropertyWithNoArguments() { PropertyObject expected = new PropertyObject(); PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); fac.TargetObject = expected; fac.TargetProperty = "Item"; Assert.Throws <FatalObjectException>(() => fac.AfterPropertiesSet()); }
public void NestedStaticProperty() { PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); fac.StaticProperty = "Oragon.Spring.Objects.Factory.Config.PropertyObject.StaticProperty.Age, Oragon.Spring.Core.Tests"; fac.AfterPropertiesSet(); Assert.AreEqual(typeof(int), fac.ObjectType); object actual = fac.GetObject(); Assert.AreEqual(PropertyObject.Age, actual); }
public void StaticPropertyViaClassAndFieldName() { PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); fac.TargetProperty = "Age"; fac.TargetType = typeof(PropertyObject); fac.AfterPropertiesSet(); object actual = fac.GetObject(); Assert.AreEqual(PropertyObject.Age, actual); }
public void StaticPropertyThatAintAssemblyQualifiedShouldStillBeResolved() { PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); fac.StaticProperty = "Oragon.Spring.Objects.Factory.Config.PropertyObject.Age"; fac.AfterPropertiesSet(); Assert.AreEqual(typeof(int), fac.ObjectType); object actual = fac.GetObject(); Assert.AreEqual(PropertyObject.Age, actual); }
public void SuperMixOfNestedIndexedStaticAndInstanceProperty() { PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); fac.StaticProperty = "Oragon.Spring.Objects.Factory.Config.PropertyObject.StaticProperty.StaticProperty.Item, Oragon.Spring.Core.Tests"; fac.Arguments = new object[] { 0 }; fac.AfterPropertiesSet(); Assert.AreEqual(typeof(int), fac.ObjectType); object actual = fac.GetObject(); Assert.AreEqual(PropertyObject.StaticProperty[0], actual); }
public void StaticPropertyCaseINsenSiTiVE() { PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); fac.StaticProperty = "System.Globalization.CultureInfo.CURRENtUiCultURE, Mscorlib"; fac.AfterPropertiesSet(); Assert.AreEqual(typeof(CultureInfo), fac.ObjectType); CultureInfo actual = fac.GetObject() as CultureInfo; Assert.IsNotNull(actual); Assert.AreEqual(CultureInfo.CurrentUICulture, actual); }
public void IndexedProperty() { PropertyObject expected = new PropertyObject(); PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); fac.TargetObject = expected; fac.TargetProperty = "Item"; fac.Arguments = new object[] { 2 }; fac.AfterPropertiesSet(); object actual = fac.GetObject(); Assert.AreEqual(expected[2], actual); }
public void InstanceProperty() { PropertyObject expected = new PropertyObject(); expected.Name = "Haruki Murakami"; PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); fac.TargetObject = expected; fac.TargetProperty = "Name"; fac.AfterPropertiesSet(); object actual = fac.GetObject(); Assert.AreEqual(expected.Name, actual); }
public void GetDateTimeDotNowToTestHandlingOfPrototypesIsCorrect() { PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); fac.TargetType = typeof(DateTime); fac.TargetProperty = "Now"; fac.IsSingleton = false; fac.AfterPropertiesSet(); DateTime then = (DateTime)fac.GetObject(); Assert.IsNotNull(then); DateTime now = (DateTime)fac.GetObject(); Assert.IsNotNull(now); Assert.IsFalse(ReferenceEquals(then, now)); }
public void IsSingleton() { PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); fac.IsSingleton = false; fac.TargetProperty = "Age"; fac.TargetType = typeof(PropertyObject); fac.AfterPropertiesSet(); object actual = fac.GetObject(); Assert.AreEqual(PropertyObject.Age, actual); PropertyObject.Age = 94; object tryTwo = fac.GetObject(); Assert.AreEqual(PropertyObject.Age, tryTwo); }
public void NestedInstanceProperty() { TestObject person = new TestObject(); person.Age = 20; TestObject spouse = new TestObject(); spouse.Age = 21; person.Spouse = spouse; PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); fac.TargetObject = person; fac.TargetProperty = "spouse.age"; fac.AfterPropertiesSet(); object actual = fac.GetObject(); int expectedAge = 21; Assert.AreEqual(expectedAge, actual); }
public void BailsWhenNotConfigured() { PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); Assert.Throws <ArgumentException>(() => fac.AfterPropertiesSet(), "One of the TargetType or TargetObject properties must be set."); }
public void BailsWhenStaticPropertyIsSetToNull() { PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); Assert.Throws <ArgumentNullException>(() => fac.StaticProperty = null); }
public void Instantiation() { PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); Assert.IsNotNull(fac.Arguments); }
public void BailsWhenStaticPropertyPassedGumpfh() { PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); Assert.Throws <ArgumentException>(() => fac.StaticProperty = "Boog"); // no field specified }