Ejemplo n.º 1
0
        //build the graph of derived requirements.
        private void AddDerivedRequirement(string type, string originalId, ReqTable.RequirementRow row)
        {
            if (!ValidateOriginalRequirement(row, originalId))
            {
                //error occurs, should not be added to build derived graph.
                return;
            }
            //add original requirement id to the current requirement's original id list.
            if (!derivedRequirements.ContainsKey(row.REQ_ID))
            {
                DerivedRequirement derivedReq
                    = new DerivedRequirement(row.REQ_ID, CoveredStatus.Unverified);
                derivedReq.AddOriginalRequirement(originalId);
                derivedRequirements.Add(row.REQ_ID, derivedReq);
            }
            else
            {
                if (!derivedRequirements[row.REQ_ID].OriginalReqs.Contains(originalId))
                {
                    DerivedRequirement derivedReq = derivedRequirements[row.REQ_ID];
                    derivedReq.AddOriginalRequirement(originalId);
                    derivedRequirements[row.REQ_ID] = derivedReq;
                }
            }

            //add all derived requirements for current requirement
            //to the derived dictionary of original requirement
            switch (type.ToLower())
            {
            case "i":
                AddDerived(originalId, row, DerivedType.Inferred);
                break;

            case "p":
                AddDerived(originalId, row, DerivedType.Partial);
                break;

            case "c":
                AddDerived(originalId, row, DerivedType.Cases);
                break;

            default:
                throw new FormatException(
                          string.Format("Unexpected derived type \"{0}\" is found in derived text in Requirement {1}:\"{2}\"," +
                                        "the type must be one of i, c or p.", type, row.REQ_ID, row.Description));
            }
        }
Ejemplo n.º 2
0
 private void AddDerived(string originalId, ReqTable.RequirementRow row, DerivedType type)
 {
     if (!derivedRequirements.ContainsKey(originalId))
     {
         DerivedRequirement originalReq
             = new DerivedRequirement(originalId, CoveredStatus.Unverified);
         originalReq.AddDerivedRequirement(row.REQ_ID, type);
         derivedRequirements.Add(originalId, originalReq);
     }
     else
     {
         if (!derivedRequirements[originalId].DerivedReqs.ContainsKey(row.REQ_ID))
         {
             DerivedRequirement originalReq = derivedRequirements[originalId];
             originalReq.AddDerivedRequirement(row.REQ_ID, type);
             derivedRequirements[originalId] = originalReq;
         }
     }
 }
Ejemplo n.º 3
0
        private void RemoveDerivedRequirmentRelationship(string oriReqId)
        {
            if (derivedRequirements.ContainsKey(oriReqId))
            {
                DerivedRequirement oReq = derivedRequirements[oriReqId];
                if (oReq.OriginalReqs.Count == 0)
                {
                    derivedRequirements.Remove(oriReqId);
                    if (requirementsToVerify.ContainsKey(oriReqId))
                    {
                        List <string> ltStrings = new List <string>();
                        ltStrings = requirementsToVerify[oriReqId];
                        requirementsToVerify.Remove(oriReqId);
                        requirementsNotToVerify.Add(oriReqId, ltStrings);
                    }
                }

                foreach (string derivedId in oReq.DerivedReqs.Keys)
                {
                    derivedRequirements[derivedId].RemoveOriginalRequirement(oriReqId);
                    RemoveDerivedRequirmentRelationship(derivedId);
                }
            }
        }
Ejemplo n.º 4
0
        //build the graph of derived requirements.
        private void AddDerivedRequirement(string type, string originalId, ReqTable.RequirementRow row)
        {
            if (!ValidateOriginalRequirement(row, originalId))
            {
                //error occurs, should not be added to build derived graph.
                return;
            }
            //add original requirement id to the current requirement's original id list.
            if (!derivedRequirements.ContainsKey(row.REQ_ID))
            {
                DerivedRequirement derivedReq
                    = new DerivedRequirement(row.REQ_ID, CoveredStatus.Unverified);
                derivedReq.AddOriginalRequirement(originalId);
                derivedRequirements.Add(row.REQ_ID, derivedReq);
            }
            else
            {
                if (!derivedRequirements[row.REQ_ID].OriginalReqs.Contains(originalId))
                {
                    DerivedRequirement derivedReq = derivedRequirements[row.REQ_ID];
                    derivedReq.AddOriginalRequirement(originalId);
                    derivedRequirements[row.REQ_ID] = derivedReq;
                }
            }

            //add all derived requirements for current requirement
            //to the derived dictionary of original requirement
            switch (type.ToLower())
            {
                case "i":
                    AddDerived(originalId, row, DerivedType.Inferred);
                    break;
                case "p":
                    AddDerived(originalId, row, DerivedType.Partial);
                    break;
                case "c":
                    AddDerived(originalId, row, DerivedType.Cases);
                    break;
                default:
                    throw new FormatException(
                        string.Format("Unexpected derived type \"{0}\" is found in derived text in Requirement {1}:\"{2}\"," +
                        "the type must be one of i, c or p.", type, row.REQ_ID, row.Description));
            }
        }
Ejemplo n.º 5
0
 private void AddDerived(string originalId, ReqTable.RequirementRow row, DerivedType type)
 {
     if (!derivedRequirements.ContainsKey(originalId))
     {
         DerivedRequirement originalReq
             = new DerivedRequirement(originalId, CoveredStatus.Unverified);
         originalReq.AddDerivedRequirement(row.REQ_ID, type);
         derivedRequirements.Add(originalId, originalReq);
     }
     else
     {
         if (!derivedRequirements[originalId].DerivedReqs.ContainsKey(row.REQ_ID))
         {
             DerivedRequirement originalReq = derivedRequirements[originalId];
             originalReq.AddDerivedRequirement(row.REQ_ID, type);
             derivedRequirements[originalId] = originalReq;
         }
     }
 }
Ejemplo n.º 6
0
        private void Load(IList <string> reqFilenames)
        {
            try
            {
                ReqTable requirementTable = null;
                ReqTable tempTable        = new ReqTable();
                foreach (string reqfile in reqFilenames)
                {
                    if (requirementTable == null)
                    {
                        requirementTable = new ReqTable();
                        requirementTable.ReadXml(XmlReader.Create(reqfile, new XmlReaderSettings()
                        {
                            XmlResolver = null
                        }));
                    }
                    else
                    {
                        tempTable.ReadXml(XmlReader.Create(reqfile, new XmlReaderSettings()
                        {
                            XmlResolver = null
                        }));
                        requirementTable.Merge(tempTable);
                        tempTable.Clear();
                    }
                }
                tempTable.Dispose();

                bool newVersion = false;
                // Now requirementTable contains all requirement tables from user's input
                // to simplify the coding, ReportingTool assumes all of them are user's required.
                foreach (ReqTable.RequirementRow row in requirementTable.Requirement)
                {
                    //remove all start or end spacese.
                    row.REQ_ID       = row.REQ_ID.Trim();
                    row.Verification = row.Verification.Trim();

                    //translate the blank to new for delta value
                    if (row.IsDeltaNull() || string.IsNullOrEmpty(row.Delta.Trim()))
                    {
                        row.Delta = "new";
                    }
                    else
                    {
                        row.Delta = row.Delta.ToLower().Trim();
                    }

                    //cache all requirements and verifications.
                    this.reqVerifications.Add(row.REQ_ID, row.Verification);

                    if (string.Compare(row.Verification, VerificationValues.DELETED, true) == 0)
                    {
                        List <string> ltStrings = new List <string>();
                        ltStrings.Add(row.Description);
                        ltStrings.Add(row.Doc_Sect);
                        ltStrings.Add(row.Scope);
                        requirementsDeleted.Add(row.REQ_ID, ltStrings);
                        continue;
                    }

                    TotalCount++;
                    if (row.IsActorNull() && row.IsScopeNull())
                    {
                        throw new InvalidOperationException(
                                  String.Format("Column Actor or Scope is expected at {0}", row.REQ_ID));
                    }

                    if (!row.IsScopeNull() && TotalCount == 1)
                    {
                        //estimate RS version from the first requirement
                        newVersion = true;
                    }

                    if (newVersion)
                    {
                        ComputRequirementV2(row);
                    }
                    else
                    {
                        ComputRequirementV1(row);
                    }
                }

                //make sure there is no duplicated id in RS Req_Id column.
                MakeSureNoDuplicateId();

                if (newVersion)
                {
                    //compute derived requirements and original requirements
                    foreach (ReqTable.RequirementRow row in requirementTable.Requirement)
                    {
                        if (ValidateDerivedRequirement(row))
                        {
                            ComputeDerivedRequirement(row);
                        }
                    }
                }

                //filter the requirement which only derived from informative requirement(s)
                foreach (string derivedId in derivedFromInformativeReqs)
                {
                    DerivedRequirement derivedReq = derivedRequirements[derivedId];
                    foreach (string originalId in derivedReq.OriginalReqs)
                    {
                        if (!informativeReqs.Contains(originalId))
                        {
                            validationErrors.Remove(derivedId);
                        }
                    }
                }

                foreach (string invalidOriReq in oriReqOutOfDeltaScope)
                {
                    RemoveDerivedRequirmentRelationship(invalidOriReq);
                }

                requirementTable.Dispose();

                //find the loop in the requirement table and throw exception when loops exist.
                FindLoop();
            }
            catch (Exception e)
            {
                throw new InvalidOperationException(
                          String.Format("[ERROR] Unable to get requirement data from specified requirement table files. Details:\r\n{0}", e.Message + e.StackTrace));
            }
        }