public void GetBytes() { var request = new SftpCloseRequest(_protocolVersion, _requestId, _handle, null); var bytes = request.GetBytes(); var expectedBytesLength = 0; #if TUNING expectedBytesLength += 4; // Length #endif expectedBytesLength += 1; // Type expectedBytesLength += 4; // RequestId expectedBytesLength += 4; // Handle length expectedBytesLength += _handle.Length; // Handle Assert.AreEqual(expectedBytesLength, bytes.Length); var sshDataStream = new SshDataStream(bytes); #if TUNING Assert.AreEqual((uint)bytes.Length - 4, sshDataStream.ReadUInt32()); #endif Assert.AreEqual((byte)SftpMessageTypes.Close, sshDataStream.ReadByte()); Assert.AreEqual(_requestId, sshDataStream.ReadUInt32()); Assert.AreEqual((uint)_handle.Length, sshDataStream.ReadUInt32()); var actualHandle = new byte[_handle.Length]; sshDataStream.Read(actualHandle, 0, actualHandle.Length); Assert.IsTrue(_handle.SequenceEqual(actualHandle)); Assert.IsTrue(sshDataStream.IsEndOfData); }