Esempio n. 1
0
        public void NothingSet()
        {
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            fac.ObjectName = "foo";
            Assert.Throws <ArgumentException>(() => fac.AfterPropertiesSet());
        }
Esempio n. 2
0
        public void JustTargetField()
        {
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            fac.TargetField = "Space";
            fac.ObjectName  = "foo";
            Assert.Throws <ArgumentException>(() => fac.AfterPropertiesSet());
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        public void IsSingleton()
        {
            FieldRetrievingFactoryObject fac = new FieldRetrievingFactoryObject();

            Assert.IsTrue(fac.IsSingleton);
        }