public void ParseWriteCommand2Test() { 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)))); Assert.AreEqual<string>("\u000600FF", target.ParseWriteCommand("\u000500FFCW00003F015678FA")); Assert.AreEqual<ushort>(0x5678, target._memory._memory[63]); }
public void ParseReadCommand2Test() { Mock<BaseSimulatorPlcCommunication> privateTarget = new Mock<BaseSimulatorPlcCommunication>(); int errorCode = 0; privateTarget.Setup<bool>(x => x.CheckForErrorReadCommand(It.IsAny<string>(), out errorCode)).Returns(true); 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)))); Assert.AreEqual<string>("\u000600FF", target.ParseWriteCommand("\u000500FFCW00002302ABCD1234E1")); Assert.AreEqual<ushort>(0xABCD, target._memory._memory[35]); Assert.AreEqual<ushort>(0x1234, target._memory._memory[36]); Assert.AreEqual<string>("\u000200FFABCD1234\u0003C3", target.ParseReadCommand("\u000500FFCR0000230208")); }