Beispiel #1
0
        private MethodInfo[] GetAllNonVirtualMethodsFromSelection()
        {
            var query =
                from method in SubjectMethods
                where MethodInfoAssertions.IsNonVirtual(method)
                select method;

            return(query.ToArray());
        }
Beispiel #2
0
        /// <summary>
        /// Asserts that the current type does not expose a method named <paramref name="name"/>
        /// with parameter types <paramref name="parameterTypes"/>.
        /// </summary>
        /// <param name="name">The name of the method.</param>
        /// <param name="parameterTypes">The method parameter types.</param>
        /// <param name="because">A formatted phrase as is supported by <see cref="M:System.String.Format(System.String,System.Object[])"/> explaining why the assertion
        ///             is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.</param>
        /// <param name="becauseArgs">Zero or more objects to format using the placeholders in <see cref="!:because"/>.</param>
        public AndConstraint <TypeAssertions> NotHaveMethod(string name, IEnumerable <Type> parameterTypes, string because = "", params object[] becauseArgs)
        {
            MethodInfo methodInfo = Subject.GetMethod(name, parameterTypes);

            string methodInfoDescription = "";

            if (methodInfo != null)
            {
                methodInfoDescription = MethodInfoAssertions.GetDescriptionFor(methodInfo);
            }

            Execute.Assertion.ForCondition(methodInfo == null)
            .BecauseOf(because, becauseArgs)
            .FailWith(string.Format("Expected method {0}({1}) to not exist{{reason}}, but it does.", methodInfoDescription,
                                    GetParameterString(parameterTypes)));

            return(new AndConstraint <TypeAssertions>(this));
        }
        private static string GetDescriptionsFor(IEnumerable <MethodInfo> methods)
        {
            IEnumerable <string> descriptions = methods.Select(method => MethodInfoAssertions.GetDescriptionFor(method));

            return(string.Join(Environment.NewLine, descriptions));
        }
Beispiel #4
0
        internal static bool IsGetterNonVirtual(PropertyInfo property)
        {
            MethodInfo getter = property.GetGetMethod(true);

            return(MethodInfoAssertions.IsNonVirtual(getter));
        }