/// <summary> /// Creates the status string for a set of paragraphs /// </summary> /// <param name="paragraphs"></param> /// <returns></returns> public static string CreateParagraphSetStatus(List <Paragraph> paragraphs) { String retVal = "Statistics : "; ParagraphSetMetrics metrics = CreateParagraphSetMetrics(paragraphs); if (metrics.SubParagraphCount > 0 && metrics.ImplementableCount > 0) { retVal += metrics.SubParagraphCount + " requirements, "; retVal += +metrics.ImplementableCount + " implementable (" + Math.Round(((float)metrics.ImplementableCount / metrics.SubParagraphCount * 100), 2) + "%), "; retVal += metrics.ImplementedCount + " implemented (" + Math.Round(((float)metrics.ImplementedCount / metrics.ImplementableCount * 100), 2) + "%), "; retVal += +metrics.UnImplementedCount + " not implemented (" + Math.Round(((float)metrics.UnImplementedCount / metrics.ImplementableCount * 100), 2) + "%), "; retVal += metrics.NewRevisionAvailable + " with new revision (" + Math.Round(((float)metrics.NewRevisionAvailable / metrics.ImplementableCount * 100), 2) + "%), "; retVal += metrics.TestedCount + " tested (" + Math.Round(((float)metrics.TestedCount / metrics.ImplementableCount * 100), 2) + "%)"; } else { retVal += "No implementable requirement selected"; } return(retVal); }
/// <summary> /// Creates the stat message according to the list of paragraphs provided /// </summary> /// <param name="paragraphs"></param> /// <returns></returns> public static ParagraphSetMetrics CreateParagraphSetMetrics(List <Paragraph> paragraphs) { ParagraphSetMetrics retVal = new ParagraphSetMetrics { SubParagraphCount = paragraphs.Count }; Dictionary <Paragraph, List <ReqRef> > paragraphsReqRefDictionary = null; foreach (Paragraph p in paragraphs) { if (paragraphsReqRefDictionary == null) { paragraphsReqRefDictionary = p.Dictionary.ParagraphsReqRefs; } if (p.ConsiderInMetrics()) { switch (p.getImplementationStatus()) { case acceptor.SPEC_IMPLEMENTED_ENUM.Impl_Implemented: retVal.ImplementableCount += 1; bool implemented = true; if (paragraphsReqRefDictionary.ContainsKey(p)) { List <ReqRef> implementations = paragraphsReqRefDictionary[p]; foreach (ReqRef implementation in implementations) { // the implementation may be also a ReqRef ReqRelated reqRelated = implementation.Enclosing as ReqRelated; if (reqRelated != null) { // Do not consider tests if (EnclosingFinder <Frame> .find(reqRelated) == null) { implemented = implemented && reqRelated.ImplementationCompleted; } } } } if (implemented) { retVal.ImplementedCount += 1; } else { retVal.UnImplementedCount += 1; } break; case acceptor.SPEC_IMPLEMENTED_ENUM.Impl_NA: case acceptor.SPEC_IMPLEMENTED_ENUM.defaultSPEC_IMPLEMENTED_ENUM: retVal.ImplementableCount += 1; retVal.UnImplementedCount += 1; break; case acceptor.SPEC_IMPLEMENTED_ENUM.Impl_NotImplementable: retVal.NotImplementable += 1; break; case acceptor.SPEC_IMPLEMENTED_ENUM.Impl_NewRevisionAvailable: retVal.ImplementableCount += 1; retVal.NewRevisionAvailable += 1; break; } } else { retVal.NotImplementable += 1; } } // Count the tested paragraphs HashSet <Paragraph> testedParagraphs = new HashSet <Paragraph>(); foreach (Dictionary dictionary in EfsSystem.Instance.Dictionaries) { foreach (Paragraph p in dictionary.CoveredRequirements()) { testedParagraphs.Add(p); } } foreach (Paragraph p in paragraphs) { if (testedParagraphs.Contains(p)) { retVal.TestedCount += 1; } } return(retVal); }
/// <summary> /// Creates the stat message according to the list of paragraphs provided /// </summary> /// <param name="paragraphs"></param> /// <returns></returns> public static ParagraphSetMetrics CreateParagraphSetMetrics(List<Paragraph> paragraphs) { ParagraphSetMetrics retVal = new ParagraphSetMetrics {SubParagraphCount = paragraphs.Count}; Dictionary<Paragraph, List<ReqRef>> paragraphsReqRefDictionary = null; foreach (Paragraph p in paragraphs) { if (paragraphsReqRefDictionary == null) { paragraphsReqRefDictionary = p.Dictionary.ParagraphsReqRefs; } if (p.ConsiderInMetrics()) { switch (p.getImplementationStatus()) { case acceptor.SPEC_IMPLEMENTED_ENUM.Impl_Implemented: retVal.ImplementableCount += 1; bool implemented = true; if (paragraphsReqRefDictionary.ContainsKey(p)) { List<ReqRef> implementations = paragraphsReqRefDictionary[p]; foreach (ReqRef implementation in implementations) { // the implementation may be also a ReqRef ReqRelated reqRelated = implementation.Enclosing as ReqRelated; if (reqRelated != null) { // Do not consider tests if (EnclosingFinder<Frame>.find(reqRelated) == null) { implemented = implemented && reqRelated.ImplementationCompleted; } } } } if (implemented) { retVal.ImplementedCount += 1; } else { retVal.UnImplementedCount += 1; } break; case acceptor.SPEC_IMPLEMENTED_ENUM.Impl_NA: case acceptor.SPEC_IMPLEMENTED_ENUM.defaultSPEC_IMPLEMENTED_ENUM: retVal.ImplementableCount += 1; retVal.UnImplementedCount += 1; break; case acceptor.SPEC_IMPLEMENTED_ENUM.Impl_NotImplementable: retVal.NotImplementable += 1; break; case acceptor.SPEC_IMPLEMENTED_ENUM.Impl_NewRevisionAvailable: retVal.ImplementableCount += 1; retVal.NewRevisionAvailable += 1; break; } } else { retVal.NotImplementable += 1; } } // Count the tested paragraphs HashSet<Paragraph> testedParagraphs = new HashSet<Paragraph>(); foreach (Dictionary dictionary in EfsSystem.Instance.Dictionaries) { foreach (Paragraph p in dictionary.CoveredRequirements()) { testedParagraphs.Add(p); } } foreach (Paragraph p in paragraphs) { if (testedParagraphs.Contains(p)) { retVal.TestedCount += 1; } } return retVal; }