private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (DialogResult.OK.Equals(ofdProjectFile.ShowDialog(this))) { projectFilePath = ofdProjectFile.FileName; projectFolderPath = Path.GetDirectoryName(projectFilePath); ProjectFileReader pfr = new ProjectFileReader(projectFilePath); opcMockProject = pfr.OpcMockProject; opcMockProject.OnProtocolAdded += new OpcMockProject.ProtocolHandler(opcMockProject_OnProtocolAdded); projectFileWriter = new ProjectFileWriter(opcMockProject, projectFolderPath); if (!File.Exists(DataFilePath())) { File.Create(DataFilePath()).Close(); } opcReader = new OpcReaderCsv(DataFilePath()); opcWriter = new OpcWriterCsv(DataFilePath()); FillOpcDataGrid(opcReader.ReadAllTags()); Text = "OPC Mock - " + opcMockProject.Name; EnableButtonsAfterDataFileLoad(); } }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { CreateProjectDialog cpd = new CreateProjectDialog(); cpd.StartPosition = FormStartPosition.CenterParent; if (DialogResult.OK.Equals(cpd.ShowDialog(this))) { opcMockProject = cpd.Project; opcMockProject.OnProtocolAdded += new OpcMockProject.ProtocolHandler(opcMockProject_OnProtocolAdded); projectFolderPath = cpd.ProjectFolderPath; projectFileWriter = new ProjectFileWriter(opcMockProject, projectFolderPath); projectFileWriter.Save(); if (!File.Exists(DataFilePath())) { File.Create(DataFilePath()).Close(); } opcReader = new OpcReaderCsv(DataFilePath()); opcWriter = new OpcWriterCsv(DataFilePath()); Text = "OPC Mock - " + opcMockProject.Name; EnableButtonsAfterDataFileLoad(); } cpd.Dispose(); }
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()); }
public void TestInitialize() { DeleteProjectFileIfExists(); projectFilePath = TestContext.TestDir + Path.DirectorySeparatorChar + PROJECT_NAME + OpcMockConstants.FileExtensionProject; projectFileWriter = new ProjectFileWriter(new OpcMockProject(PROJECT_NAME), TestContext.TestDir); }