public void ProcessReadWriteCommandThrowsNotImplementedExceptionTest()
        {
            Mock<BaseSimulatorPlcCommunication> privateTarget = new Mock<BaseSimulatorPlcCommunication>();
            BaseSimulatorPlcCommunication_Accessor target = new BaseSimulatorPlcCommunication_Accessor(new PrivateObject(privateTarget.Object, new PrivateType(typeof(BaseSimulatorPlcCommunication))));

            // calling read before write
            target.Open();
            target.Read();
        }
        public void ProcessReadWriteCommand2Test()
        {
            Mock<BaseSimulatorPlcCommunication> privateTarget = new Mock<BaseSimulatorPlcCommunication>();
            int errorCode = 0;
            privateTarget.Setup<bool>(x => x.CheckForErrorWriteCommand(It.IsAny<string>(), out errorCode)).Returns(true);

            BaseSimulatorPlcCommunication_Accessor target = new BaseSimulatorPlcCommunication_Accessor(new PrivateObject(privateTarget.Object, new PrivateType(typeof(BaseSimulatorPlcCommunication))));

            target.Open();
            target.Write("\u000500FFCW00012002ABCD1234DF");
            Assert.AreEqual<BaseSimulatorPlcCommunication_Accessor.State>(BaseSimulatorPlcCommunication_Accessor.State.CW, target._machineState);
            Assert.AreEqual<string>(new PlcMemoryAcknowledge().CommandToString(), target.Read());
            Assert.AreEqual<BaseSimulatorPlcCommunication_Accessor.State>(BaseSimulatorPlcCommunication_Accessor.State.READY, target._machineState);
        }
        public void ProcessReadWriteCommand3Test()
        {
            Mock<BaseSimulatorPlcCommunication> privateTarget = new Mock<BaseSimulatorPlcCommunication>();
            BaseSimulatorPlcCommunication_Accessor target = new BaseSimulatorPlcCommunication_Accessor(new PrivateObject(privateTarget.Object, new PrivateType(typeof(BaseSimulatorPlcCommunication))));

            // invalid command
            target.Open();
            target.Write("\u000500FFXX00012002ABCD1234F5");

            privateTarget.Verify(x => x.ErrorMethod(), Times.Exactly(1));
            Assert.AreEqual<BaseSimulatorPlcCommunication_Accessor.State>(BaseSimulatorPlcCommunication_Accessor.State.CW, target._machineState);
            Assert.AreEqual<string>("\u001500FF06", target.Read());
            Assert.AreEqual<BaseSimulatorPlcCommunication_Accessor.State>(BaseSimulatorPlcCommunication_Accessor.State.READY, target._machineState);
        }
        public void ProcessReadWriteCommand1Test()
        {
            Mock<BaseSimulatorPlcCommunication> privateTarget = new Mock<BaseSimulatorPlcCommunication>();
            int errorCode = 0;
            privateTarget.Setup<bool>(x => x.CheckForErrorReadCommand(It.IsAny<string>(), out errorCode)).Returns(true);
            BaseSimulatorPlcCommunication_Accessor target = new BaseSimulatorPlcCommunication_Accessor(new PrivateObject(privateTarget.Object, new PrivateType(typeof(BaseSimulatorPlcCommunication))));

            target._memory._memory[0x5] = 0xABCD;
            target._memory._memory[0x6] = 0x1234;

            target.Open();
            target.Write("\u000500FFCR0000050208");
            Assert.AreEqual<BaseSimulatorPlcCommunication_Accessor.State>(BaseSimulatorPlcCommunication_Accessor.State.CR, target._machineState);
            Assert.AreEqual<string>("ABCD1234", PlcMemoryReadData.Create(target.Read()).Data);
            Assert.AreEqual<BaseSimulatorPlcCommunication_Accessor.State>(BaseSimulatorPlcCommunication_Accessor.State.ACK, target._machineState);
            target.Write("\u000600FF");
            Assert.AreEqual<BaseSimulatorPlcCommunication_Accessor.State>(BaseSimulatorPlcCommunication_Accessor.State.READY, target._machineState);
        }