public void GetBytes() { var request = new SftpFSetStatRequest(_protocolVersion, _requestId, _handle, _attributes, null); var bytes = request.GetBytes(); var expectedBytesLength = 0; expectedBytesLength += 4; // Length expectedBytesLength += 1; // Type expectedBytesLength += 4; // RequestId expectedBytesLength += 4; // Handle length expectedBytesLength += _handle.Length; // Handle expectedBytesLength += _attributesBytes.Length; // Attributes Assert.AreEqual(expectedBytesLength, bytes.Length); var sshDataStream = new SshDataStream(bytes); Assert.AreEqual((uint) bytes.Length - 4, sshDataStream.ReadUInt32()); Assert.AreEqual((byte) SftpMessageTypes.FSetStat, 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)); var actualAttributes = new byte[_attributesBytes.Length]; sshDataStream.Read(actualAttributes, 0, actualAttributes.Length); Assert.IsTrue(_attributesBytes.SequenceEqual(actualAttributes)); Assert.IsTrue(sshDataStream.IsEndOfData); }