Example #1
0
        public void ReadInputsResponseToString()
        {
            // Arrange
            var response = new ReadInputsResponse();

            response.Initialize(new byte[] { 5, ModbusFunctionCodes.ReadInputs, 2, 1, 1 });

            // Act/Assert
            Assert.Equal($"Read 16 inputs from slave 5", response.ToString());
            response.Dispose();
        }
        public void CreatesReadInputsResponse()
        {
            // Arrange/Act
            ReadInputsResponse response = (ReadInputsResponse)ModbusResponseFactory.CreateResponse <ReadInputsResponse>(
                new byte[] { 11, ModbusFunctionCodes.ReadInputs, 1, 1 });

            // Assert
            Assert.Equal(ModbusFunctionCodes.ReadInputs, response.FunctionCode);
            Assert.Equal(11, response.SlaveAddress);
            Assert.Equal(new bool[] { true, false, false, false }, response.Data.Slice(0, 4).ToArray());
        }