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);
        }
Example #2
0
        public void Add_Line_Appends_A_Line_At_The_End()
        {
            OpcMockProtocol omp = new OpcMockProtocol(PROTOCOL_NAME);

            string line1 = "Set;tagPath1;tagValue1;192";
            string lineEqualToLine1 = "Set;tagPath2;tagValue2;192";

            omp.Append(new ProtocolLine(line1));
            omp.Append(new ProtocolLine(lineEqualToLine1));

            ///PROPOSAL expose IEnumberable instead of List
            Assert.AreEqual(new ProtocolLine(lineEqualToLine1), omp.Lines[1]);
        }
Example #3
0
        public void Append_For_StringArray_Appends_All_Lines()
        {
            OpcMockProtocol protocol = new OpcMockProtocol(PROTOCOL_NAME);

            string[] testArray = new string[] { "Set; tagPath1; tagValue; 192", "Set;tagPath2;tagValue;192", "Set;tagPath3;tagValue;192" };

            protocol.Append(testArray);

            Assert.AreEqual(new ProtocolLine("Set;tagPath1;tagValue;192"), protocol.Lines[0]);
            Assert.AreEqual(new ProtocolLine("Set;tagPath2;tagValue;192"), protocol.Lines[1]);
            Assert.AreEqual(new ProtocolLine("Set;tagPath3;tagValue;192"), protocol.Lines[2]);
        }
Example #4
0
        public void Adding_A_Line_Raises_LineAdded_Event()
        {
            bool eventRaised = false;

            OpcMockProtocol protocol = new OpcMockProtocol(PROTOCOL_NAME);

            protocol.OnProtocolLineAdded += delegate (object sender, ProtocolLineAddedArgs plaArgs) { eventRaised = true; };

            protocol.Append(new ProtocolLine("Set;tagPath;tagValue;192"));

            Assert.IsTrue(eventRaised);
        }
Example #5
0
        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);
            }
        }
Example #6
0
        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);
            }
        }