protected void Arrange() { var random = new Random(); _path = random.Next().ToString(CultureInfo.InvariantCulture); _handle = new[] { (byte)random.Next(byte.MinValue, byte.MaxValue) }; _fileAttributes = SftpFileAttributes.Empty; _bufferSize = (uint)random.Next(0, 1000); _readBufferSize = (uint)random.Next(0, 1000); _writeBufferSize = (uint)random.Next(0, 1000); _sftpSessionMock = new Mock<ISftpSession>(MockBehavior.Strict); var sequence = new MockSequence(); _sftpSessionMock.InSequence(sequence) .Setup(p => p.RequestOpen(_path, Flags.Write | Flags.Truncate, true)) .Returns(_handle); _sftpSessionMock.InSequence(sequence).Setup(p => p.RequestFStat(_handle)).Returns(_fileAttributes); _sftpSessionMock.InSequence(sequence) .Setup(p => p.CalculateOptimalReadLength(_bufferSize)) .Returns(_readBufferSize); _sftpSessionMock.InSequence(sequence) .Setup(p => p.CalculateOptimalWriteLength(_bufferSize, _handle)) .Returns(_writeBufferSize); _sftpSessionMock.InSequence(sequence) .Setup(p => p.IsOpen) .Returns(true); _sftpSessionMock.InSequence(sequence) .Setup(p => p.RequestClose(_handle)); _sftpFileStream = new SftpFileStream(_sftpSessionMock.Object, _path, FileMode.Create, FileAccess.Write, (int)_bufferSize); }
public void CanReadTest() { SftpSession session = null; // TODO: Initialize to an appropriate value string path = string.Empty; // TODO: Initialize to an appropriate value FileMode mode = new FileMode(); // TODO: Initialize to an appropriate value SftpFileStream target = new SftpFileStream(session, path, mode); // TODO: Initialize to an appropriate value bool actual; actual = target.CanRead; Assert.Inconclusive("Verify the correctness of this test method."); }
public void BeginWriteTest() { SftpSession session = null; // TODO: Initialize to an appropriate value string path = string.Empty; // TODO: Initialize to an appropriate value FileMode mode = new FileMode(); // TODO: Initialize to an appropriate value SftpFileStream target = new SftpFileStream(session, path, mode); // TODO: Initialize to an appropriate value byte[] buffer = null; // TODO: Initialize to an appropriate value int offset = 0; // TODO: Initialize to an appropriate value int count = 0; // TODO: Initialize to an appropriate value AsyncCallback callback = null; // TODO: Initialize to an appropriate value object state = null; // TODO: Initialize to an appropriate value IAsyncResult expected = null; // TODO: Initialize to an appropriate value IAsyncResult actual; actual = target.BeginWrite(buffer, offset, count, callback, state); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public SshFileStream(SftpFileStream fs) { _fs = fs; }
protected void Arrange() { _random = new Random(); _path = _random.Next().ToString(CultureInfo.InvariantCulture); _handle = new[] {(byte) _random.Next(byte.MinValue, byte.MaxValue)}; _fileAttributes = SftpFileAttributes.Empty; _bufferSize = (uint) _random.Next(1, 1000); _readBufferSize = (uint) _random.Next(0, 1000); _writeBufferSize = (uint) _random.Next(500, 1000); _data = new byte[(_writeBufferSize * 2) + 15]; _random.NextBytes(_data); _offset = _random.Next(1, 5); // to get multiple SSH_FXP_WRITE messages (and verify the offset is updated correctly), we make sure // the number of bytes to write is at least two times the write buffer size; we write a few extra bytes to // ensure the buffer is not empty after the writes so we can verify whether Length, Dispose and Flush // flush the buffer _count = ((int) _writeBufferSize*2) + _random.Next(1, 5); _expectedWrittenByteCount = (2 * _writeBufferSize); _expectedBufferedByteCount = (int)(_count - _expectedWrittenByteCount); _expectedBufferedBytes = _data.Take(_offset + (int)_expectedWrittenByteCount, _expectedBufferedByteCount); _sftpSessionMock = new Mock<ISftpSession>(MockBehavior.Strict); _sequence = new MockSequence(); _sftpSessionMock.InSequence(_sequence) .Setup(p => p.RequestOpen(_path, Flags.Write | Flags.Truncate, true)) .Returns(_handle); _sftpSessionMock.InSequence(_sequence).Setup(p => p.RequestFStat(_handle)).Returns(_fileAttributes); _sftpSessionMock.InSequence(_sequence) .Setup(p => p.CalculateOptimalReadLength(_bufferSize)) .Returns(_readBufferSize); _sftpSessionMock.InSequence(_sequence) .Setup(p => p.CalculateOptimalWriteLength(_bufferSize, _handle)) .Returns(_writeBufferSize); _sftpSessionMock.InSequence(_sequence) .Setup(p => p.IsOpen) .Returns(true); _sftpSessionMock.InSequence(_sequence) .Setup(p => p.RequestWrite(_handle, 0, _data, _offset, (int) _writeBufferSize, It.IsAny<AutoResetEvent>(), null)); _sftpSessionMock.InSequence(_sequence) .Setup(p => p.RequestWrite(_handle, _writeBufferSize, _data, _offset + (int) _writeBufferSize, (int)_writeBufferSize, It.IsAny<AutoResetEvent>(), null)); _sftpFileStream = new SftpFileStream(_sftpSessionMock.Object, _path, FileMode.Create, FileAccess.Write, (int) _bufferSize); }
public void TimeoutTest() { SftpSession session = null; // TODO: Initialize to an appropriate value string path = string.Empty; // TODO: Initialize to an appropriate value FileMode mode = new FileMode(); // TODO: Initialize to an appropriate value SftpFileStream target = new SftpFileStream(session, path, mode); // TODO: Initialize to an appropriate value TimeSpan expected = new TimeSpan(); // TODO: Initialize to an appropriate value TimeSpan actual; target.Timeout = expected; actual = target.Timeout; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void WriteTest() { SftpSession session = null; // TODO: Initialize to an appropriate value string path = string.Empty; // TODO: Initialize to an appropriate value FileMode mode = new FileMode(); // TODO: Initialize to an appropriate value SftpFileStream target = new SftpFileStream(session, path, mode); // TODO: Initialize to an appropriate value byte[] buffer = null; // TODO: Initialize to an appropriate value int offset = 0; // TODO: Initialize to an appropriate value int count = 0; // TODO: Initialize to an appropriate value target.Write(buffer, offset, count); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public void SetLengthTest() { SftpSession session = null; // TODO: Initialize to an appropriate value string path = string.Empty; // TODO: Initialize to an appropriate value FileMode mode = new FileMode(); // TODO: Initialize to an appropriate value SftpFileStream target = new SftpFileStream(session, path, mode); // TODO: Initialize to an appropriate value long value = 0; // TODO: Initialize to an appropriate value target.SetLength(value); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public void SeekTest() { SftpSession session = null; // TODO: Initialize to an appropriate value string path = string.Empty; // TODO: Initialize to an appropriate value FileMode mode = new FileMode(); // TODO: Initialize to an appropriate value SftpFileStream target = new SftpFileStream(session, path, mode); // TODO: Initialize to an appropriate value long offset = 0; // TODO: Initialize to an appropriate value SeekOrigin origin = new SeekOrigin(); // TODO: Initialize to an appropriate value long expected = 0; // TODO: Initialize to an appropriate value long actual; actual = target.Seek(offset, origin); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void ReadTest() { SftpSession session = null; // TODO: Initialize to an appropriate value string path = string.Empty; // TODO: Initialize to an appropriate value FileMode mode = new FileMode(); // TODO: Initialize to an appropriate value SftpFileStream target = new SftpFileStream(session, path, mode); // TODO: Initialize to an appropriate value byte[] buffer = null; // TODO: Initialize to an appropriate value int offset = 0; // TODO: Initialize to an appropriate value int count = 0; // TODO: Initialize to an appropriate value int expected = 0; // TODO: Initialize to an appropriate value int actual; actual = target.Read(buffer, offset, count); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void EndWriteTest() { SftpSession session = null; // TODO: Initialize to an appropriate value string path = string.Empty; // TODO: Initialize to an appropriate value FileMode mode = new FileMode(); // TODO: Initialize to an appropriate value SftpFileStream target = new SftpFileStream(session, path, mode); // TODO: Initialize to an appropriate value IAsyncResult asyncResult = null; // TODO: Initialize to an appropriate value target.EndWrite(asyncResult); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public void EndReadTest() { SftpSession session = null; // TODO: Initialize to an appropriate value string path = string.Empty; // TODO: Initialize to an appropriate value FileMode mode = new FileMode(); // TODO: Initialize to an appropriate value SftpFileStream target = new SftpFileStream(session, path, mode); // TODO: Initialize to an appropriate value IAsyncResult asyncResult = null; // TODO: Initialize to an appropriate value int expected = 0; // TODO: Initialize to an appropriate value int actual; actual = target.EndRead(asyncResult); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }