public void ValidateResponse_RequestAheadOfResponse_RequestsReread() { ModbusIpTransport transport = new ModbusIpTransport(MockRepository.GenerateStub <IStreamResource>()); IModbusMessage request = new ReadCoilsInputsRequest(Modbus.ReadCoils, 1, 1, 1); request.TransactionId = 5; IModbusMessage response = new ReadCoilsInputsResponse(Modbus.ReadCoils, 1, 1, null); response.TransactionId = 4; Assert.IsFalse(transport.ValidateResponse(request, response)); }
public void ValidateResponse_MismatchingTransactionIds() { ModbusIpTransport transport = new ModbusIpTransport(MockRepository.GenerateStub <IStreamResource>()); IModbusMessage request = new ReadCoilsInputsRequest(Modbus.ReadCoils, 1, 1, 1); request.TransactionId = 5; IModbusMessage response = new ReadCoilsInputsResponse(Modbus.ReadCoils, 1, 1, null); response.TransactionId = 6; Assert.Throws <IOException>(() => transport.ValidateResponse(request, response)); }
public void ValidateResponse_MismatchingTransactionIds() { var transport = new ModbusIpTransport(StreamResourceMock, new ModbusFactory(), NullModbusLogger.Instance); var request = new ReadCoilsInputsRequest(ModbusFunctionCodes.ReadCoils, 1, 1, 1); request.TransactionId = 5; var response = new ReadCoilsInputsResponse(ModbusFunctionCodes.ReadCoils, 1, 1, null); response.TransactionId = 6; Assert.Throws <IOException>(() => transport.ValidateResponse(request, response)); }
public void ValidateResponse_MismatchingTransactionIds() { var transport = new ModbusIpTransport(StreamResourceMock.Object); var request = new ReadCoilsInputsRequest(Modbus.ReadCoils, 1, 1, 1); request.TransactionId = 5; var response = new ReadCoilsInputsResponse(Modbus.ReadCoils, 1, 1, null); response.TransactionId = 6; Assert.Throws <IOException>(() => transport.ValidateResponse(request, response)); }
public void ValidateResponse() { ModbusIpTransport transport = new ModbusIpTransport(MockRepository.GenerateStub <IStreamResource>()); IModbusMessage request = new ReadCoilsInputsRequest(Modbus.ReadCoils, 1, 1, 1); request.TransactionId = 5; IModbusMessage response = new ReadCoilsInputsResponse(Modbus.ReadCoils, 1, 1, null); response.TransactionId = 5; // no exception is thrown transport.ValidateResponse(request, response); }
public void ValidateResponse() { var transport = new ModbusIpTransport(StreamResourceMock, new ModbusFactory(), NullModbusLogger.Instance); var request = new ReadCoilsInputsRequest(ModbusFunctionCodes.ReadCoils, 1, 1, 1); request.TransactionId = 5; var response = new ReadCoilsInputsResponse(ModbusFunctionCodes.ReadCoils, 1, 1, null); response.TransactionId = 5; // no exception is thrown transport.ValidateResponse(request, response); }
public void ValidateResponse_PassesWithMatchingTransactionDetails() { ModbusIpTransport transport = new ModbusIpTransport(MockRepository.GenerateStub <IStreamResource>()); IModbusMessage request = new ReadCoilsInputsRequest(Modbus.ReadCoils, 1, 1, 1); request.TransactionId = 5; IModbusMessage response = new ReadCoilsInputsResponse(Modbus.ReadCoils, 1, 1, null); response.TransactionId = 5; // no exception is thrown, and return true Assert.IsTrue(transport.ValidateResponse(request, response)); }
public void ValidateResponse() { var transport = new ModbusIpTransport(StreamResourceMock); var request = new ReadCoilsInputsRequest(Modbus.ReadCoils, 1, 1, 1); request.TransactionId = 5; var response = new ReadCoilsInputsResponse(Modbus.ReadCoils, 1, 1, null); response.TransactionId = 5; // no exception is thrown transport.ValidateResponse(request, response); }
public void ValidateResponse_RequestAheadOfResponse_RequestsReread() { ModbusIpTransport transport = new ModbusIpTransport(MockRepository.GenerateStub<IStreamResource>()); IModbusMessage request = new ReadCoilsInputsRequest(Modbus.ReadCoils, 1, 1, 1); request.TransactionId = 5; IModbusMessage response = new ReadCoilsInputsResponse(Modbus.ReadCoils, 1, 1, null); response.TransactionId = 4; Assert.IsFalse(transport.ValidateResponse(request, response)); }
public void ValidateResponse_PassesWithMatchingTransactionDetails() { ModbusIpTransport transport = new ModbusIpTransport(MockRepository.GenerateStub<IStreamResource>()); IModbusMessage request = new ReadCoilsInputsRequest(Modbus.ReadCoils, 1, 1, 1); request.TransactionId = 5; IModbusMessage response = new ReadCoilsInputsResponse(Modbus.ReadCoils, 1, 1, null); response.TransactionId = 5; // no exception is thrown, and return true Assert.IsTrue(transport.ValidateResponse(request, response)); }
public void ValidateResponse_MismatchingTransactionIds() { ModbusIpTransport transport = new ModbusIpTransport(MockRepository.GenerateStub<IStreamResource>()); IModbusMessage request = new ReadCoilsInputsRequest(Modbus.ReadCoils, 1, 1, 1); request.TransactionId = 5; IModbusMessage response = new ReadCoilsInputsResponse(Modbus.ReadCoils, 1, 1, null); response.TransactionId = 6; Assert.Throws<IOException>(() => transport.ValidateResponse(request, response)); }
public void ValidateResponse() { ModbusIpTransport transport = new ModbusIpTransport(MockRepository.GenerateStub<IStreamResource>()); IModbusMessage request = new ReadCoilsInputsRequest(Modbus.ReadCoils, 1, 1, 1); request.TransactionId = 5; IModbusMessage response = new ReadCoilsInputsResponse(Modbus.ReadCoils, 1, 1, null); response.TransactionId = 5; // no exception is thrown transport.ValidateResponse(request, response); }