Ejemplo n.º 1
0
        public void GetNonExistantPropertyException()
        {
            ObjectWrapper wrapper = new ObjectWrapper(new TestObject("Rick", 23));
            PropertyAccessExceptionsException ex
                = new PropertyAccessExceptionsException(wrapper, new PropertyAccessException[]
            {
            });
            PropertyAccessException nullException = ex.GetPropertyAccessException("Age");

            Assert.IsNull(nullException);
        }
Ejemplo n.º 2
0
        public void GetPropertyExceptions()
        {
            ObjectWrapper wrapper = new ObjectWrapper(new TestObject("Rick", 23));
            PropertyAccessExceptionsException ex
                = new PropertyAccessExceptionsException(wrapper, new PropertyAccessException[]
            {
                new TypeMismatchException(new PropertyChangeEventArgs("Doctor", new NestedTestObject("Foo"), "rubbish"), typeof(INestedTestObject)),
                new MethodInvocationException(new TargetInvocationException("Bad format", new FormatException("'12' is not a valid argument for 'foo'..")), new PropertyChangeEventArgs("Friends", new ArrayList(), "trash"))
            });
            PropertyAccessException doctorPropertyException = ex.GetPropertyAccessException("Doctor");

            Assert.IsNotNull(doctorPropertyException);
            Assert.AreEqual("typeMismatch", doctorPropertyException.ErrorCode);
            Assert.AreEqual("Foo", ((NestedTestObject)doctorPropertyException.PropertyChangeArgs.OldValue).Company);
            PropertyAccessException friendsPropertyException = ex.GetPropertyAccessException("Friends");

            Assert.IsNotNull(friendsPropertyException);
            Assert.AreEqual("methodInvocation", friendsPropertyException.ErrorCode);
            Assert.AreEqual(wrapper, ex.ObjectWrapper);
            Assert.AreEqual(wrapper.WrappedInstance, ex.BindObject);
            Assert.AreEqual(ex.Message, ex.ToString());
        }