public void SaveShould_Write_Protocol_Segment()
        {
            OpcMockProject projectWithOneProtocol = new OpcMockProject(PROJECT_NAME);
            string firstProtocolName = "firstProtocol";

            projectWithOneProtocol.AddProtocol(new OpcMockProtocol(firstProtocolName));

            projectFileWriter = new ProjectFileWriter(projectWithOneProtocol, TestContext.TestDir);

            XElement fileContentStartXml = new XElement("project",
                                                            new XElement("project_name", PROJECT_NAME),
                                                            new XElement("protocol_list",
                                                                new XElement("protocol", firstProtocolName)));

            SaveContentToFileAndCheckResult(fileContentStartXml.ToString());
        }
예제 #2
0
        private void newToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            CreateProtocolDialog cpd = new CreateProtocolDialog();

            cpd.StartPosition = FormStartPosition.CenterParent;

            if (DialogResult.OK.Equals(cpd.ShowDialog(this)))
            {
                try
                {
                    opcMockProject.AddProtocol(cpd.OpcMockProtocol);
                }
                catch (DuplicateProtocolNameException exProtocolName)
                {
                    MessageBox.Show(this, exProtocolName.Message + "\n" + exProtocolName.ProtocolName, "Protocol exists", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            cpd.Dispose();
        }
예제 #3
0
        private OpcMockProject ParseFileContent()
        {
            OpcMockProject omp;

            XmlDocument doc = new XmlDocument();
            doc.Load(projectFilePath);

            string projectName = doc.GetElementsByTagName("project_name")[0].InnerText;

            omp = new OpcMockProject(projectName);

            List<string> protocolNames = new List<string>();

            XmlNodeList protocolTags = doc.GetElementsByTagName("protocol");

            foreach (XmlNode protocolTag in protocolTags)
            {
                omp.AddProtocol(new OpcMockProtocol(protocolTag.InnerText));
            }

            return omp;
        }
예제 #4
0
        private OpcMockProject ParseFileContent()
        {
            OpcMockProject omp;

            XmlDocument doc = new XmlDocument();

            doc.Load(projectFilePath);

            string projectName = doc.GetElementsByTagName("project_name")[0].InnerText;

            omp = new OpcMockProject(projectName);

            List <string> protocolNames = new List <string>();

            XmlNodeList protocolTags = doc.GetElementsByTagName("protocol");

            foreach (XmlNode protocolTag in protocolTags)
            {
                omp.AddProtocol(new OpcMockProtocol(protocolTag.InnerText));
            }

            return(omp);
        }