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 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);
            Thread.Sleep(TimeSpan.FromMilliseconds(10));
            DateTime now = (DateTime)fac.GetObject();

            Assert.IsNotNull(now);
            Assert.AreNotEqual(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 NestedStaticProperty()
		{
			PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject();
			fac.StaticProperty = "Spring.Objects.Factory.Config.PropertyObject.StaticProperty.Age, Spring.Core.Tests";
			fac.AfterPropertiesSet();
			Assert.AreEqual(typeof (int), fac.ObjectType);
			object actual = fac.GetObject();
			Assert.AreEqual(PropertyObject.Age, actual);
		}
		public void MixOfNestedIndexedStaticAndInstanceProperty()
		{
			PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject();
			fac.StaticProperty = "Spring.Objects.Factory.Config.PropertyObject.StaticProperty.Item, 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 BailsWhenReadingIndexedPropertyWithNoArguments()
        {
            PropertyObject expected             = new PropertyObject();
            PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject();

            fac.TargetObject   = expected;
            fac.TargetProperty = "Item";
            fac.AfterPropertiesSet();
            fac.GetObject();
        }
        public void NestedStaticProperty()
        {
            PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject();

            fac.StaticProperty = "Spring.Objects.Factory.Config.PropertyObject.StaticProperty.Age, Spring.Core.Tests";
            fac.AfterPropertiesSet();
            Assert.AreEqual(typeof(int), fac.ObjectType);
            object actual = fac.GetObject();

            Assert.AreEqual(PropertyObject.Age, actual);
        }
        public void StaticPropertyThatAintAssemblyQualifiedShouldStillBeResolved()
        {
            PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject();

            fac.StaticProperty = "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 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 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 SuperMixOfNestedIndexedStaticAndInstanceProperty()
        {
            PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject();

            fac.StaticProperty = "Spring.Objects.Factory.Config.PropertyObject.StaticProperty.StaticProperty.Item, 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 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 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 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 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 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 BailsWhenReadingIndexedPropertyWithNoArguments()
		{
			PropertyObject expected = new PropertyObject();
			PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject();
			fac.TargetObject = expected;
			fac.TargetProperty = "Item";
			fac.AfterPropertiesSet();
			fac.GetObject();
		}
		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 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 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 = "Spring.Objects.Factory.Config.PropertyObject.Age";
			fac.AfterPropertiesSet();
			Assert.AreEqual(typeof (int), fac.ObjectType);
			object actual = fac.GetObject();
			Assert.AreEqual(PropertyObject.Age, actual);
		}