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()); }
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(); }
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; }
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); }