public void Test_CCIItemWithReferenceDataIsValid()
        {
            CciItem cci = new CciItem();

            cci.cciId       = "CCI-2345";
            cci.status      = "myStatus";
            cci.publishDate = DateTime.Now.ToShortDateString();
            cci.contributor = "Cingulara";
            cci.definition  = "This is my definition";
            cci.type        = "thisType";
            cci.parameter   = "myParams";
            cci.note        = "man this is complicated!";

            CciReference cciRef = new CciReference();

            cciRef.creator  = "NIST";
            cciRef.title    = "This is my title here";
            cciRef.location = "My location";
            cciRef.index    = "AU-9 1.a(2)";
            cci.references.Add(cciRef);

            // test things out
            Assert.True(cci != null);
            Assert.True(!string.IsNullOrEmpty(cci.cciId));
            Assert.True(!string.IsNullOrEmpty(cci.status));
            Assert.True(!string.IsNullOrEmpty(cci.publishDate));
            Assert.True(!string.IsNullOrEmpty(cci.contributor));
            Assert.True(!string.IsNullOrEmpty(cci.definition));
            Assert.True(!string.IsNullOrEmpty(cci.type));
            Assert.True(!string.IsNullOrEmpty(cci.parameter));
            Assert.True(!string.IsNullOrEmpty(cci.note));
            Assert.True(cci.references != null);
            Assert.True(cci.references.Count == 1);
        }
        public void Test_CciItemWithDataIsValid()
        {
            CciItem cci = new CciItem();

            cci.cciId       = "cciId";
            cci.status      = "status";
            cci.publishDate = "mydate";
            cci.contributor = "mycontributor";
            cci.definition  = "mydefinition";
            cci.type        = "mytype";
            cci.parameter   = "param1";
            cci.note        = "mynote";
            CciReference ccir = new CciReference();

            ccir.creator      = "me";
            ccir.title        = "mytitle";
            ccir.version      = "v1";
            ccir.location     = "mylocation";
            ccir.index        = "2.3";
            ccir.majorControl = "AC-2";
            cci.references.Add(ccir);

            // test things out
            Assert.True(cci != null);
            Assert.True(cci.references != null);
            Assert.True(cci.references.Count == 1);
            Assert.True(cci.references[0] != null);
        }
        public void Test_CCIReferenceWithDataIsValid()
        {
            CciReference cci = new CciReference();

            cci.creator      = "NIST";
            cci.title        = "This is my title here";
            cci.location     = "My location";
            cci.index        = "AU-9 1.a(2)";
            cci.majorControl = "AU-9";

            // test things out
            Assert.True(cci != null);
            Assert.True(!string.IsNullOrEmpty(cci.creator));
            Assert.True(!string.IsNullOrEmpty(cci.title));
            Assert.True(!string.IsNullOrEmpty(cci.location));
            Assert.True(!string.IsNullOrEmpty(cci.index));
            Assert.True(!string.IsNullOrEmpty(cci.majorControl));
        }
        /// <summary>
        /// Generate the list of CCI items from the NIST listing in the XML file included
        /// </summary>
        /// <returns>The list of CCI items for use in filtering</returns>
        public static List <CciItem> LoadNistToCci()
        {
            List <CciItem> cciList = new List <CciItem>();
            CciItem        item;       // the CCI item
            CciReference   reference;  // list of references
            int            len    = 0; // the length to find the major control piece
            XmlDocument    xmlDoc = new XmlDocument();
            // get the file path for the CCI to NIST listing
            var ccipath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "/U_CCI_List.xml";

            if (File.Exists(ccipath))
            {
                xmlDoc.LoadXml(File.ReadAllText(ccipath));
                XmlNodeList itemList = xmlDoc.GetElementsByTagName("cci_item");

                foreach (XmlElement child in itemList)
                {
                    item = new CciItem();
                    // get all the main pieces of the XML record for this
                    foreach (XmlElement ccidata in child.ChildNodes)
                    {
                        if (ccidata.Name == "status")
                        {
                            item.status = ccidata.InnerText;
                        }
                        else if (ccidata.Name == "publishdate")
                        {
                            item.publishDate = ccidata.InnerText;
                        }
                        else if (ccidata.Name == "contributor")
                        {
                            item.contributor = ccidata.InnerText;
                        }
                        else if (ccidata.Name == "definition")
                        {
                            item.definition = ccidata.InnerText;
                        }
                        else if (ccidata.Name == "type")
                        {
                            item.type = ccidata.InnerText;
                        }
                        else if (ccidata.Name == "parameter")
                        {
                            item.parameter = ccidata.InnerText;
                        }
                        else if (ccidata.Name == "note")
                        {
                            item.note = ccidata.InnerText;
                        }
                        else if (ccidata.Name == "references")
                        {
                            // cycle through all the references
                            foreach (XmlElement cciref in ccidata.ChildNodes)
                            {
                                reference = new CciReference();
                                foreach (XmlAttribute attr in cciref.Attributes)
                                {
                                    if (attr.Name == "creator")
                                    {
                                        reference.creator = attr.InnerText;
                                    }
                                    else if (attr.Name == "title")
                                    {
                                        reference.title = attr.InnerText;
                                    }
                                    else if (attr.Name == "version")
                                    {
                                        reference.version = attr.InnerText;
                                    }
                                    else if (attr.Name == "location")
                                    {
                                        reference.location = attr.InnerText;
                                    }
                                    else if (attr.Name == "index")
                                    {
                                        reference.index = attr.InnerText;
                                        len             = EndOfIndex(attr.InnerText);
                                        if (len > 0)
                                        {
                                            reference.majorControl = attr.InnerText.Substring(0, len);
                                        }
                                        else
                                        {
                                            reference.majorControl = reference.index;
                                        }
                                    }
                                }
                                item.references.Add(reference);
                            }
                        }
                    }
                    // get the CCI ID
                    if (child.Attributes.Count == 1)
                    {
                        item.cciId = child.Attributes[0].InnerText;
                    }
                    cciList.Add(item);
                }
            }
            return(cciList);
        }
        public void Test_NewCCIReferenceIsValid()
        {
            CciReference cci = new CciReference();

            Assert.True(cci != null);
        }