Exemple #1
0
        private static MSTest CreateMethodTest(ITypeInfo typeInfo, IMethodInfo methodInfo)
        {
            MSTest methodTest = new MSTest(methodInfo.Name, methodInfo);

            methodTest.Kind       = TestKinds.Test;
            methodTest.IsTestCase = true;

            PopulateTestMethodMetadata(methodInfo, methodTest);

            // Add XML documentation.
            string xmlDocumentation = methodInfo.GetXmlDocumentation();

            if (xmlDocumentation != null)
            {
                methodTest.Metadata.SetValue(MetadataKeys.XmlDocumentation, xmlDocumentation);
            }

            return(methodTest);
        }
        /// <summary>
        /// Initializes a test for a method after it has been added to the test model.
        /// </summary>
        /// <param name="methodScope">The method scope.</param>
        /// <param name="method">The method.</param>
        protected virtual void InitializeTest(IPatternScope methodScope, IMethodInfo method)
        {
            string xmlDocumentation = method.GetXmlDocumentation();

            if (xmlDocumentation != null)
            {
                methodScope.TestBuilder.AddMetadata(MetadataKeys.XmlDocumentation, xmlDocumentation);
            }

            methodScope.Process(method);

            if (method.IsGenericMethodDefinition)
            {
                foreach (IGenericParameterInfo parameter in method.GenericArguments)
                {
                    methodScope.Consume(parameter, false, DefaultGenericParameterPattern);
                }
            }

            foreach (IParameterInfo parameter in method.Parameters)
            {
                methodScope.Consume(parameter, false, DefaultMethodParameterPattern);
            }
        }
        /// <summary>
        /// Initializes a test for a method after it has been added to the test model.
        /// </summary>
        /// <param name="methodScope">The method scope.</param>
        /// <param name="method">The method.</param>
        protected virtual void InitializeTest(IPatternScope methodScope, IMethodInfo method)
        {
            string xmlDocumentation = method.GetXmlDocumentation();
            if (xmlDocumentation != null)
                methodScope.TestBuilder.AddMetadata(MetadataKeys.XmlDocumentation, xmlDocumentation);

            methodScope.Process(method);

            if (method.IsGenericMethodDefinition)
            {
                foreach (IGenericParameterInfo parameter in method.GenericArguments)
                    methodScope.Consume(parameter, false, DefaultGenericParameterPattern);
            }

            foreach (IParameterInfo parameter in method.Parameters)
                methodScope.Consume(parameter, false, DefaultMethodParameterPattern);
        }
        private static MSTest CreateMethodTest(ITypeInfo typeInfo, IMethodInfo methodInfo)
        {
            MSTest methodTest = new MSTest(methodInfo.Name, methodInfo);
            methodTest.Kind = TestKinds.Test;
            methodTest.IsTestCase = true;

            PopulateTestMethodMetadata(methodInfo, methodTest);

            // Add XML documentation.
            string xmlDocumentation = methodInfo.GetXmlDocumentation();
            if (xmlDocumentation != null)
                methodTest.Metadata.SetValue(MetadataKeys.XmlDocumentation, xmlDocumentation);

            return methodTest;
        }