public void ReadIntTest()
        {
            var comPort         = Substitute.For <IComPort>();
            var protocolFinsTcp = new PlcOmronFins(comPort, 0);
            var values          = new int[] { };

            comPort.IsConnected.Returns(true);
            comPort.BytesToRead.Returns(8, 26);
            comPort.Read(Arg.Any <byte[]>(), Arg.Any <int>(), Arg.Any <int>()).Returns(
                ci =>
            {
                Array.Copy(new byte[] { 0x46, 0x49, 0x4E, 0x53, 0x00, 0x00, 0x00, 0x1A }, ci.ArgAt <byte[]>(0), 8);

                return(ci.ArgAt <byte[]>(0).Count());
            },
                ci =>
            {
                Array.Copy(new byte[] { 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x02, 0x00, 0xC0, 0x00, 0x00, 0x21, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x11, 0x22, 0x33, 0x44 }, ci.ArgAt <byte[]>(0), 26);

                return(ci.ArgAt <byte[]>(0).Count());
            }
                );

            values = protocolFinsTcp.Read <int>(new DataAddress()
            {
                Value  = "D1234",
                Type   = DataAddressType.Int,
                Offset = 0
            }).ToArray();

            Assert.AreEqual(BitConverter.ToInt32(new byte[] { 0x22, 0x11, 0x44, 0x33 }, 0), values[0]);
        }
        public void ReadBoolTest()
        {
            var comPort         = Substitute.For <IComPort>();
            var protocolFinsTcp = new PlcOmronFins(comPort, 0);
            var values          = new bool[] { };

            comPort.IsConnected.Returns(true);
            comPort.BytesToRead.Returns(8, 23);
            comPort.Read(Arg.Any <byte[]>(), Arg.Any <int>(), Arg.Any <int>()).Returns(
                ci =>
            {
                Array.Copy(new byte[] { 0x46, 0x49, 0x4E, 0x53, 0x00, 0x00, 0x00, 0x17 }, ci.ArgAt <byte[]>(0), 8);

                return(ci.ArgAt <byte[]>(0).Count());
            },
                ci =>
            {
                Array.Copy(new byte[] { 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x02, 0x00, 0xC0, 0x00, 0x00, 0x21, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01 }, ci.ArgAt <byte[]>(0), 23);

                return(ci.ArgAt <byte[]>(0).Count());
            }
                );

            values = protocolFinsTcp.Read <bool>(new DataAddress()
            {
                Value  = "D1234",
                Type   = DataAddressType.Boolean,
                Offset = 1
            }).ToArray();

            Assert.AreEqual(true, values[0]);
        }