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

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

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

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