Beispiel #1
0
        public void sendReadMessage_Coils_readCoil()
        {
            var slaveConnector = new Moq.Mock <ITCPSlaveConnector>();

            slave = new TCPSlave(slaveConnector.Object);
            ModbusTCPReadMessage <bool> message = new ModbusTCPReadMessage <bool>()
            {
                functionCode = ModbusTCPReadMessage <bool> .FunctionCode.ReadCoils,
                startReg     = 30,
                length       = 40,
            };

            slave.sendReadMessage <bool>(message);

            //verify the correct send Message is called
            slaveConnector.Verify(s => s.ReadCoils(message.startReg, (message.length)), Moq.Times.Once);
        }
Beispiel #2
0
        public void sendReadMessage_InputRegisters_readInputRegisters()
        {
            var slaveConnector = new Moq.Mock <ITCPSlaveConnector>();

            slave = new TCPSlave(slaveConnector.Object);
            ModbusTCPReadMessage <int> message = new ModbusTCPReadMessage <int>()
            {
                functionCode = ModbusTCPReadMessage <int> .FunctionCode.ReadInputRegisters,
                startReg     = 30,
                length       = 40,
            };

            slave.sendReadMessage <int>(message);

            //verify the correct send Message is called
            slaveConnector.Verify(s => s.ReadInputRegisters(message.startReg, (message.length)));
        }