Exemplo n.º 1
0
        /// <summary>
        /// Verifies that a method has appropriate Guard Clauses in place.
        /// </summary>
        /// <param name="methodInfo">The method.</param>
        /// <remarks>
        /// <para>
        /// Exactly which Guard Clauses are verified is defined by
        /// <see cref="BehaviorExpectation" />.
        /// </para>
        /// </remarks>
        public override void Verify(MethodInfo methodInfo)
        {
            if (methodInfo == null)
                throw new ArgumentNullException("methodInfo");

            if (methodInfo.IsEqualsMethod())
                return;

            EnsureTypeIsNotGeneric(methodInfo.ReflectedType);

            var method = this.CreateMethod(methodInfo);

            var isReturnValueIterator =
                typeof(System.Collections.IEnumerable).IsAssignableFrom(methodInfo.ReturnType) ||
                typeof(System.Collections.IEnumerator).IsAssignableFrom(methodInfo.ReturnType);

            this.Verify(method, isReturnValueIterator);
        }
        /// <summary>
        /// Verifies that a method has appripriate Guard Clauses in place.
        /// </summary>
        /// <param name="methodInfo">The method.</param>
        /// <remarks>
        /// <para>
        /// Exactly which Guard Clauses are verified is defined by
        /// <see cref="BehaviorExpectation" />.
        /// </para>
        /// </remarks>
        public override void Verify(MethodInfo methodInfo)
        {
            if (methodInfo == null)
                throw new ArgumentNullException("methodInfo");

            if (methodInfo.IsEqualsMethod())
                return;

            var owner = this.Builder.CreateAnonymous(methodInfo.ReflectedType);
            var method = new InstanceMethod(methodInfo, owner);

            var isReturnValueIterator =
                typeof(System.Collections.IEnumerable).IsAssignableFrom(methodInfo.ReturnType) ||
                typeof(System.Collections.IEnumerator).IsAssignableFrom(methodInfo.ReturnType);

            this.Verify(method, isReturnValueIterator);
        }
        /// <summary>
        /// Verifies that a method has appripriate Guard Clauses in place.
        /// </summary>
        /// <param name="methodInfo">The method.</param>
        /// <remarks>
        /// <para>
        /// Exactly which Guard Clauses are verified is defined by
        /// <see cref="BehaviorExpectation" />.
        /// </para>
        /// </remarks>
        public override void Verify(MethodInfo methodInfo)
        {
            if (methodInfo == null)
                throw new ArgumentNullException("methodInfo");

            if (methodInfo.IsEqualsMethod())
                return;

            var owner = this.Builder.CreateAnonymous(methodInfo.ReflectedType);
            var method = new InstanceMethod(methodInfo, owner);
            this.Verify(method);
        }