public void ReadByte_NotOpened() { _stream = new SCPChannelStream(); Assert.AreEqual("NotOpened", _stream.Status); Assert.Catch <SCPClientInvalidStatusException>( () => _stream.ReadByte(1000) ); }
/// <summary> /// Read a byte and check the status code. /// </summary> /// <param name="stream">Channel stream</param> /// <exception cref="SCPClientException">Response was a warning or an error.</exception> private void CheckResponse(SCPChannelStream stream) { byte response = stream.ReadByte(_protocolTimeout); if (response == 0) { // OK return; } if (response == 1 || response == 2) { // Warning or Error // followed by a message which is terminated by LF byte[] messageData = stream.ReadUntil(LF, _protocolTimeout); string message = _encoding.GetString(messageData, 0, messageData.Length - 1); throw new SCPClientException(message); } throw new SCPClientException("Invalid response"); }
public void ReadByte_Timeout() { Assert.Catch <SCPClientTimeoutException>( () => _stream.ReadByte(1000) ); }
public void ReadByte_NotOpened() { _stream = new SCPChannelStream(); Assert.AreEqual("NotOpened", _stream.Status); _stream.ReadByte(1000); }
public void ReadByte_Timeout() { _stream.ReadByte(1000); }