public void Save_Stores_ProtocolLines_In_The_File() { string projectName = "projectName"; string protocolName = "protocolName"; OpcMockProtocol omp = new OpcMockProtocol(protocolName); string ompLine1 = "Set;tagPath1;tagValue1;192"; string ompLine2 = "Set;tagPath2;tagValue2;192"; omp.Append(new ProtocolLine(ompLine1)); omp.Append(new ProtocolLine(ompLine2)); string protocolFilePath = TestContext.TestDeploymentDir + Path.DirectorySeparatorChar + protocolName + FileExtensionContants.FileExtensionProtocol; ProtocolWriter protocolWriter = new ProtocolWriter(TestContext.TestDeploymentDir, projectName); protocolWriter.Save(omp); string expectedFileContent = ompLine1 + Environment.NewLine + ompLine2 + Environment.NewLine; string actualFileContent = File.ReadAllText(protocolFilePath); Assert.AreEqual(expectedFileContent, actualFileContent); File.Delete(protocolFilePath); }
private void saveAllToolStripMenuItem_Click(object sender, EventArgs e) { ProtocolWriter protocolWriter = new ProtocolWriter(GetProjectFolderPath(), opcMockProject.Name); foreach (OpcMockProtocol omp in opcMockProject.Protocols) { protocolWriter.Save(omp); } }
public void ProtocolWriter_Is_Created_With_A_Folder_Path() { string folderPath = "folderPath"; string projectName = "projectName"; ProtocolWriter protocolWriter = new ProtocolWriter(folderPath, projectName); Assert.AreEqual(folderPath, protocolWriter.FolderPath); Assert.AreEqual(projectName, protocolWriter.ProjectName); }
public void Save_Creates_A_Protocol_File_In_The_FolderPath() { string projectName = "projectName"; string protocolName = "protocolName"; OpcMockProtocol opcMockProtocol = new OpcMockProtocol(protocolName); ProtocolWriter protocolWriter = new ProtocolWriter(TestContext.TestDeploymentDir, projectName); protocolWriter.Save(opcMockProtocol); string protocolFilePath = TestContext.TestDeploymentDir + Path.DirectorySeparatorChar + protocolName + FileExtensionContants.FileExtensionProtocol; Assert.IsTrue(File.Exists(protocolFilePath)); File.Delete(protocolFilePath); }
private void saveToolStripMenuItem1_Click(object sender, EventArgs e) { if (cbProtocols.SelectedIndex > 0) { ProtocolWriter protocolWriter = new ProtocolWriter(GetProjectFolderPath(), opcMockProject.Name); OpcMockProtocol currentProtocol = new OpcMockProtocol(cbProtocols.SelectedText); foreach (string line in tbProtocol.Lines) { try { currentProtocol.Append(new ProtocolLine(line)); } catch (ArgumentException) { //End of protocol reached } } protocolWriter.Save(currentProtocol); } }