public void GetReply_StatVfsReplyInfo() { var bsize = (ulong)_random.Next(0, int.MaxValue); var frsize = (ulong)_random.Next(0, int.MaxValue); var blocks = (ulong)_random.Next(0, int.MaxValue); var bfree = (ulong)_random.Next(0, int.MaxValue); var bavail = (ulong)_random.Next(0, int.MaxValue); var files = (ulong)_random.Next(0, int.MaxValue); var ffree = (ulong)_random.Next(0, int.MaxValue); var favail = (ulong)_random.Next(0, int.MaxValue); var sid = (ulong)_random.Next(0, int.MaxValue); var namemax = (ulong)_random.Next(0, int.MaxValue); var sshDataStream = new SshDataStream(4 + 1 + 4 + 88); sshDataStream.Position = 4; // skip 4 bytes for SSH packet length sshDataStream.WriteByte((byte)SftpMessageTypes.Attrs); sshDataStream.Write(_responseId); sshDataStream.Write(bsize); sshDataStream.Write(frsize); sshDataStream.Write(blocks); sshDataStream.Write(bfree); sshDataStream.Write(bavail); sshDataStream.Write(files); sshDataStream.Write(ffree); sshDataStream.Write(favail); sshDataStream.Write(sid); sshDataStream.Write((ulong)0x2); sshDataStream.Write(namemax); var sshData = sshDataStream.ToArray(); var target = new SftpExtendedReplyResponse(_protocolVersion); target.Load(sshData, 5, sshData.Length - 5); var reply = target.GetReply <StatVfsReplyInfo>(); Assert.IsNotNull(reply); var information = reply.Information; Assert.IsNotNull(information); Assert.AreEqual(bavail, information.AvailableBlocks); Assert.AreEqual(favail, information.AvailableNodes); Assert.AreEqual(frsize, information.BlockSize); Assert.AreEqual(bsize, information.FileSystemBlockSize); Assert.AreEqual(bfree, information.FreeBlocks); Assert.AreEqual(ffree, information.FreeNodes); Assert.IsFalse(information.IsReadOnly); Assert.AreEqual(namemax, information.MaxNameLenght); Assert.AreEqual(sid, information.Sid); Assert.IsFalse(information.SupportsSetUid); Assert.AreEqual(blocks, information.TotalBlocks); Assert.AreEqual(files, information.TotalNodes); }
public void Load() { var sshDataStream = new SshDataStream(4 + 1 + 4 + 88); sshDataStream.Write(_responseId); sshDataStream.Write(_bsize); sshDataStream.Write(_frsize); sshDataStream.Write(_blocks); sshDataStream.Write(_bfree); sshDataStream.Write(_bavail); sshDataStream.Write(_files); sshDataStream.Write(_ffree); sshDataStream.Write(_favail); sshDataStream.Write(_sid); sshDataStream.Write((ulong)0x1); sshDataStream.Write(_namemax); var extendedReplyResponse = new SftpExtendedReplyResponse(SftpSession.MaximumSupportedVersion); extendedReplyResponse.Load(sshDataStream.ToArray()); Assert.AreEqual(_responseId, extendedReplyResponse.ResponseId); var target = extendedReplyResponse.GetReply <StatVfsReplyInfo>(); Assert.IsNotNull(target.Information); var information = target.Information; Assert.AreEqual(_bavail, information.AvailableBlocks); Assert.AreEqual(_favail, information.AvailableNodes); Assert.AreEqual(_frsize, information.BlockSize); Assert.AreEqual(_bsize, information.FileSystemBlockSize); Assert.AreEqual(_bfree, information.FreeBlocks); Assert.AreEqual(_ffree, information.FreeNodes); Assert.IsTrue(information.IsReadOnly); Assert.AreEqual(_namemax, information.MaxNameLenght); Assert.AreEqual(_sid, information.Sid); Assert.IsTrue(information.SupportsSetUid); Assert.AreEqual(_blocks, information.TotalBlocks); Assert.AreEqual(_files, information.TotalNodes); }