示例#1
0
        /// <summary>
        ///     Provides the set of covered requirements by the model
        /// </summary>
        /// <param name="aDictionary">The model</param>
        /// <param name="covered">Indicates if we need compute covered or non covered requirements</param>
        /// <returns></returns>
        public static HashSet <Paragraph> CoveredRequirements(Dictionary aDictionary, bool covered)
        {
            HashSet <Paragraph> retVal = new HashSet <Paragraph>();

            ICollection <Paragraph> applicableParagraphs = aDictionary.ApplicableParagraphs;
            Dictionary <Paragraph, List <ReqRef> > paragraphsReqRefDictionary = aDictionary.ParagraphsReqRefs;

            foreach (Paragraph paragraph in applicableParagraphs)
            {
                bool implemented = paragraph.getImplementationStatus() ==
                                   acceptor.SPEC_IMPLEMENTED_ENUM.Impl_Implemented;
                if (implemented)
                {
                    if (paragraphsReqRefDictionary.ContainsKey(paragraph))
                    {
                        List <ReqRef> implementations = paragraphsReqRefDictionary[paragraph];
                        for (int i = 0; i < implementations.Count; i++)
                        {
                            // the implementation may be also a ReqRef
                            if (implementations[i].Enclosing is ReqRelated)
                            {
                                ReqRelated reqRelated = implementations[i].Enclosing as ReqRelated;
                                // Do not consider tests
                                if (EnclosingFinder <Frame> .find(reqRelated) == null)
                                {
                                    implemented = implemented && reqRelated.ImplementationCompleted;
                                }
                            }
                        }
                    }
                }
                if (implemented == covered)
                {
                    retVal.Add(paragraph);
                }
            }
            return(retVal);
        }
示例#2
0
        /// <summary>
        ///     Creates a table for a given set of paragraphs
        /// </summary>
        /// <param name="paragraphs">The paragraphs to display</param>
        /// <param name="dictionary">The dictionary</param>
        /// <returns></returns>
        private void CreateImplementedParagraphsTable(HashSet <Paragraph> paragraphs, Dictionary dictionary)
        {
            Dictionary <Paragraph, List <ReqRef> > paragraphsReqRefDictionary = dictionary.ParagraphsReqRefs;

            foreach (Paragraph paragraph in paragraphs)
            {
                Cell previousCell = null;

                if (paragraphsReqRefDictionary.ContainsKey(paragraph))
                {
                    AddSubParagraph("Requirement " + paragraph.FullId);
                    AddTable(new string[] { "Requirement " + paragraph.FullId }, new int[] { 40, 60, 40 });
                    AddRow(paragraph.Text);

                    foreach (ReqRef reqRef in paragraph.Implementations)
                    {
                        string fullName = null;
                        string comment  = null;

                        ReqRelated reqRelated = reqRef.Enclosing as ReqRelated;
                        if (reqRelated != null)
                        {
                            if (reqRelated is TestCase) /* TODO: review it */
                            {
                                fullName = "TEST CASE " + reqRelated.Name;
                            }
                            else if (reqRelated is StateMachine) /* TODO: review it */
                            {
                                fullName = reqRelated.Name;
                            }
                            else
                            {
                                fullName = reqRelated.FullName;
                            }
                            comment = reqRelated.Comment;
                        }
                        else
                        {
                            Paragraph par = reqRef.Enclosing as Paragraph;
                            if (par != null) /* TODO: review it */
                            {
                                fullName = "PARAGRAPH " + paragraph.FullId;
                                comment  = paragraph.Comment;
                            }
                        }

                        if (fullName != null && comment != null)
                        {
                            if (previousCell == null)
                            {
                                AddRow("Associated implementation", fullName, comment);
                                previousCell = lastRow.Cells[0];
                            }
                            else
                            {
                                if (AddRow("", fullName, comment) != null)
                                {
                                    previousCell.MergeDown += 1;
                                }
                                else
                                {
                                    throw new Exception("Error: tried to add an empty row in the spec coverage report");
                                }
                            }
                        }
                    }
                    CloseSubParagraph();
                }
            }
        }