示例#1
0
        public void TestPropertyInnerExceptionTest()
        {
            Exception         innerException = new Exception("Inner exception");
            PropertyException exception      = new PropertyException("Property Exception Messsage", innerException);

            Assert.AreEqual(exception.Message, "Property Exception Messsage");
            Assert.AreEqual(exception.InnerException, innerException);
        }
 private PropertyInfo Validate(PropertyInfo property)
 {
     if (!property.HasGetAndSet())
     {
         throw PropertyException.MissingAccessors(property);
     }
     return(property);
 }
        /// <summary>
        /// Validates a chain of properties.
        /// All properties must be readable, and the last property must be writable.
        /// </summary>
        /// <param name="props"></param>
        private void Validate(IList <PropertyInfo> props)
        {
            var cantBeRead = props.FirstOrDefault(p => !p.CanRead);

            if (cantBeRead != null)
            {
                throw PropertyException.MissingGetAccessor(cantBeRead);
            }

            var last = props.Last();

            if (!last.CanWrite)
            {
                throw PropertyException.MissingSetAccessor(last);
            }
        }
示例#4
0
        public void TestPropertyMessageTest()
        {
            PropertyException exception = new PropertyException("Property Exception Messsage");

            Assert.AreEqual(exception.Message, "Property Exception Messsage");
        }
示例#5
0
        public void TestPropertyDefaultTest()
        {
            PropertyException exception = new PropertyException();

            Assert.AreEqual(exception.Message, "Exception of type 'WebTestSuite.Exceptions.PropertyException' was thrown.");
        }
示例#6
0
 protected virtual IEnumerable <Message> Translate([NotNull] ExceptionContext context, [NotNull] PropertyException pe)
 {
     yield return(BuildMessage(pe.ToString()));
 }