Exemple #1
0
        public void BailsOnNonExistantProperty()
        {
            PropertyObject expected             = new PropertyObject();
            PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject();

            fac.TargetObject   = expected;
            fac.TargetProperty = "Blister";
            Assert.Throws <InvalidPropertyException>(() => fac.AfterPropertiesSet());
        }
Exemple #2
0
        public void BailsOnWriteOnlyProperty()
        {
            PropertyObject expected             = new PropertyObject();
            PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject();

            fac.TargetObject   = expected;
            fac.TargetProperty = "Greenness";
            Assert.Throws <NotWritablePropertyException>(() => fac.AfterPropertiesSet());
        }
Exemple #3
0
        public void BailsWhenReadingIndexedPropertyWithNoArguments()
        {
            PropertyObject expected             = new PropertyObject();
            PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject();

            fac.TargetObject   = expected;
            fac.TargetProperty = "Item";
            Assert.Throws <FatalObjectException>(() => fac.AfterPropertiesSet());
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
        }