コード例 #1
0
 /// <summary>
 /// Tries to query the categories.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="names">The names.</param>
 /// <returns>True if found.</returns>
 protected override bool TryGetCategories(
     ICustomAttributeProviderEx element,
     out IEnumerable <string> names)
 {
     names = null;
     return(false);
 }
コード例 #2
0
        /// <summary>
        /// Tries the read expected exception.
        /// </summary>
        /// <param name="target">
        /// The method.
        /// </param>
        /// <param name="exceptionType">
        /// Type of the exception.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public override bool TryReadExpectedException(ICustomAttributeProviderEx target, out TypeEx exceptionType)
        {
            var attribute = AttributeHelper.GetAttribute(target, ExpectedExceptionAttribute);

            if (attribute != null)
            {
                var attributeType = attribute.GetType();

                // read exception type using reflection.
                var field = attributeType.GetField("expectedException", BindingFlags.NonPublic | BindingFlags.Instance);
                if (field != null)
                {
                    var  t = field.GetValue(attribute) as Type;
                    bool isClass;
                    if (t != null && ReflectionHelper.TryGetIsClass(t, out isClass) && isClass &&
                        !ReflectionHelper.ContainsGenericParameters(t))
                    {
                        exceptionType = MetadataFromReflection.GetType(t);
                        return(true);
                    }
                }
            }

            exceptionType = null;
            return(false);
        }
コード例 #3
0
        /// <summary>
        /// Tries the get categories.
        /// </summary>
        /// <param name="element">
        /// The element.
        /// </param>
        /// <param name="names">
        /// The names.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        protected override bool TryGetCategories(ICustomAttributeProviderEx element, out IEnumerable <string> names)
        {
            SafeDebug.AssumeNotNull(element, "element");

            // TODO
            names = null;
            return(false);
        }
コード例 #4
0
 /// <summary>
 /// Tries the read expected exception.
 /// </summary>
 /// <param name="target">
 /// The method.
 /// </param>
 /// <param name="exceptionType">
 /// Type of the exception.
 /// </param>
 /// <returns>
 /// The <see cref="bool"/>.
 /// </returns>
 public override bool TryReadExpectedException(ICustomAttributeProviderEx target, out TypeEx exceptionType)
 {
     exceptionType = null;
     return(false);
 }
コード例 #5
0
 protected override bool TryGetCategories(
     ICustomAttributeProviderEx element,
     out IEnumerable<string> names)
 {
     names = new string[] { };
     return false;
 }
コード例 #6
0
        /// <summary>
        /// Tries the get categories.
        /// </summary>
        /// <param name="element">
        /// The element.
        /// </param>
        /// <param name="names">
        /// The names.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        protected override bool TryGetCategories(ICustomAttributeProviderEx element, out IEnumerable<string> names)
        {
            SafeDebug.AssumeNotNull(element, "element");

            // TODO
            names = null;
            return false;
        }
コード例 #7
0
        /// <summary>
        /// Tries the read expected exception.
        /// </summary>
        /// <param name="target">
        /// The method.
        /// </param>
        /// <param name="exceptionType">
        /// Type of the exception.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public override bool TryReadExpectedException(ICustomAttributeProviderEx target, out TypeEx exceptionType)
        {
            var attribute = AttributeHelper.GetAttribute(target, ExpectedExceptionAttribute);
            if (attribute != null)
            {
                var attributeType = attribute.GetType();

                // read exception type using reflection.
                var field = attributeType.GetField("expectedException", BindingFlags.NonPublic | BindingFlags.Instance);
                if (field != null)
                {
                    var t = field.GetValue(attribute) as Type;
                    bool isClass;
                    if (t != null && ReflectionHelper.TryGetIsClass(t, out isClass) && isClass
                        && !ReflectionHelper.ContainsGenericParameters(t))
                    {
                        exceptionType = MetadataFromReflection.GetType(t);
                        return true;
                    }
                }
            }

            exceptionType = null;
            return false;
        }
コード例 #8
0
 /// <inheritdoc/>
 public override bool TryReadExpectedException(ICustomAttributeProviderEx target, out TypeEx exceptionType)
 {
     // xUnit.net does not have an [ExpectedException] attribute
     exceptionType = null;
     return false;
 }
コード例 #9
0
 /// <summary>
 /// Tries the read expected exception.
 /// </summary>
 /// <param name="target">
 /// The method.
 /// </param>
 /// <param name="exceptionType">
 /// Type of the exception.
 /// </param>
 /// <returns>
 /// The <see cref="bool"/>.
 /// </returns>
 public override bool TryReadExpectedException(ICustomAttributeProviderEx target, out TypeEx exceptionType)
 {
     exceptionType = null;
     return false;
 }
コード例 #10
0
 /// <inheritdoc/>
 public override bool TryReadExpectedException(ICustomAttributeProviderEx target, out TypeEx exceptionType)
 {
     // xUnit.net does not have an [ExpectedException] attribute
     exceptionType = null;
     return(false);
 }