示例#1
0
        /// <summary>
        /// The add test case element.
        /// </summary>
        /// <param name="assemblyObjectList">
        /// The assembly object list.
        /// </param>
        /// <param name="methodInfo">
        /// The method info.
        /// </param>
        /// <param name="methodDocumentation">
        /// The method documentation.
        /// </param>
        private void AddTestCaseElement(TestObjectCollection assemblyObjectList, EhMethodInfo methodInfo, MethodTags methodDocumentation)
        {
            Log.Enter(this, string.Format("AddTestCaseElement: {0}", methodInfo.MethodName));

            var parent = assemblyObjectList.FirstOrDefault(n => n.Name == methodInfo.MethodName);

            if (parent == null)
            {
                var testCase = new TestCase();

                testCase.Name = methodInfo.MethodDisplayName;

                var lastNamespaceSegment = GetLastNamespaceSegment(methodInfo.Namespace);
                testCase.DisplayName = string.Format("{0}.{1}.{2}", lastNamespaceSegment, methodInfo.ClassName, methodInfo.MethodName);

                testCase.Description = methodDocumentation.GetDocumentationText();

                testCase.AssemblyMethodRefId = methodInfo.CustomAttributGuid;

                testCase.AssemblyName = Path.GetFileName(methodInfo.AssemblyFullPath);
                testCase.Parameters   = this.GetTestParameterCollection(methodDocumentation);

                assemblyObjectList.Add(testCase);
            }
        }
示例#2
0
        /// <summary>
        /// The get method documentation.
        /// </summary>
        /// <param name="methodInfo">
        /// The method info.
        /// </param>
        /// <param name="methodDocumentation">
        /// The xml document.
        /// </param>
        /// <returns>
        /// The <see cref="MethodTags"/>.
        /// </returns>
        private MethodTags GetMethodTags(EhMethodInfo methodInfo, XmlNode methodDocumentation)
        {
            if (methodInfo != null)
            {
                var methodTags = new MethodTags(methodInfo.MethodName);

                // Nach Prameter suchen
                var methodParams = methodInfo.ParameterInfo;

                foreach (var paramTag in methodParams.Select(methodParam => new ParamTag(methodParam.Name, methodParam.ParameterType)))
                {
                    methodTags.Parameter.Add(paramTag);
                }

                return(this.AddMethodDocumentation(methodInfo, methodDocumentation, methodTags));
            }

            return(new MethodTags(string.Empty));
        }
示例#3
0
        /// <summary>
        /// The add method documentation.
        /// </summary>
        /// <param name="methodInfo">
        /// The method info.
        /// </param>
        /// <param name="xmlDocument">
        /// The xml document.
        /// </param>
        /// <param name="methodTags">
        /// The method tags.
        /// </param>
        /// <returns>
        /// The <see cref="MethodTags"/>.
        /// </returns>
        private MethodTags AddMethodDocumentation(EhMethodInfo methodInfo, XmlNode xmlDocument, MethodTags methodTags)
        {
            // nach Methoden in docuDoc suchen
            if (methodInfo != null)
            {
                var path             = "M:" + methodInfo.MethodFullName + "." + methodInfo.MethodName;
                var xmlDocuOfMethods = xmlDocument.SelectNodes("//member[starts-with(@name, '" + path + "')]");

                if (xmlDocuOfMethods != null)
                {
                    foreach (var xmlDocuOfMethod in xmlDocuOfMethods)
                    {
                        var methoddocu = new XmlDocument();
                        methoddocu.LoadXml("<root>" + ((XmlElement)xmlDocuOfMethod).InnerXml + "</root>");

                        // Summary hinzufügen
                        methodTags.Summary = this.GetDocumentationTag(methoddocu, methodTags.Summary) as SummaryTag;

                        // Return hinzufügen
                        methodTags.Return = this.GetDocumentationTag(methoddocu, methodTags.Return) as ReturnTag;

                        // Parameter hinzufügen
                        var xmlNodeList = methoddocu.SelectNodes("//param[starts-with(@name, '')]");
                        if (xmlNodeList != null)
                        {
                            var dokuParamsCount = xmlNodeList.Count;

                            // Anzahl der Parameter vergleichen
                            if (methodTags.Parameter.Parameters.Count() <= 0 || methodTags.Parameter.Parameters.Count() != dokuParamsCount)
                            {
                                continue;
                            }

                            for (var i = 0; i <= methodTags.Parameter.Parameters.Count() - 1; i++)
                            {
                                var dokuParams = methoddocu.SelectNodes(methodTags.Parameter.Parameters[i].SearchTag);

                                if (dokuParams != null)
                                {
                                    if (dokuParams.Count > 1)
                                    {
                                        Log.Error(this, string.Format("Parameter '{0}' mehrfach in Methode '{1}' vorhanden ", methodTags.Parameter.Parameters[i].Name, methodInfo.MethodName));
                                    }
                                    else if (dokuParams.Count < 1)
                                    {
                                        Log.Error(this, string.Format("Parameter '{0}' nicht in Methode '{1}' vorhanden ", methodTags.Parameter.Parameters[i].Name, methodInfo.MethodName));
                                    }
                                    else if (dokuParams.Count == 1)
                                    {
                                        methodTags.Parameter.Parameters[i].DocumentationTagFound = true;
                                        methodTags.Parameter.Parameters[i] = this.GetDocumentationParameterTag(dokuParams[0], methodTags.Parameter.Parameters[i]);
                                    }
                                }
                                else
                                {
                                    Log.Error(this, string.Format("Parameter '{0}' nicht in Methode '{1}' vorhanden ", methodTags.Parameter.Parameters[i].Name, methodInfo.MethodName));
                                }
                            }

                            methodTags.Parameter.DocumentationTagFound = true;
                        }

                        return(methodTags);
                    }
                }
            }

            return(methodTags);
        }