示例#1
0
        public void ReadByteTest()
        {
            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
            int            expected = 0;                                       // TODO: Initialize to an appropriate value
            int            actual;

            actual = target.ReadByte();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
示例#2
0
        public void ReadShouldStartFromEndOfStream()
        {
            SftpSessionMock.InSequence(_sequence).Setup(p => p.IsOpen).Returns(true);
            SftpSessionMock.InSequence(_sequence)
            .Setup(p => p.RequestRead(_handle, (uint)_length, _readBufferSize))
            .Returns(Array <byte> .Empty);

            var byteRead = _sftpFileStream.ReadByte();

            Assert.AreEqual(-1, byteRead);

            SftpSessionMock.Verify(p => p.RequestRead(_handle, (uint)_length, _readBufferSize), Times.Once);
            SftpSessionMock.Verify(p => p.IsOpen, Times.Exactly(4));
        }
        public void ReadShouldReadStartFromSamePositionAsBeforeSetLength()
        {
            SftpSessionMock.InSequence(_sequence).Setup(p => p.IsOpen).Returns(true);
            SftpSessionMock.InSequence(_sequence)
            .Setup(p => p.RequestRead(_handle, (uint)(_readBytes.Length + _writeBytes.Length), _readBufferSize))
            .Returns(new byte[] { 0x0f });

            var byteRead = _sftpFileStream.ReadByte();

            Assert.AreEqual(0x0f, byteRead);

            SftpSessionMock.Verify(p => p.RequestRead(_handle, (uint)(_readBytes.Length + _writeBytes.Length), _readBufferSize), Times.Once);
            SftpSessionMock.Verify(p => p.IsOpen, Times.Exactly(4));
        }
示例#4
0
        public void ReadByteShouldStartReadingAtBeginningOfFile()
        {
            var data = GenerateRandom(5, _random);

            SftpSessionMock.InSequence(MockSequence).Setup(p => p.IsOpen).Returns(true);
            SftpSessionMock.InSequence(MockSequence).Setup(p => p.RequestRead(_handle, 0UL, _readBufferSize))
            .Returns(data);

            var actual = _target.ReadByte();

            Assert.AreEqual(data[0], actual);

            SftpSessionMock.Verify(p => p.IsOpen, Times.Exactly(1));
            SftpSessionMock.Verify(p => p.RequestRead(_handle, 0UL, _readBufferSize), Times.Once);
        }
示例#5
0
        public void ReadByteShouldThrowNotSupportedException()
        {
            SftpSessionMock.InSequence(MockSequence).Setup(p => p.IsOpen).Returns(true);

            try
            {
                _target.ReadByte();
                Assert.Fail();
            }
            catch (NotSupportedException ex)
            {
                Assert.IsNull(ex.InnerException);
                Assert.AreEqual("Read not supported.", ex.Message);
            }

            SftpSessionMock.Verify(p => p.IsOpen, Times.Exactly(1));
        }
示例#6
0
 protected override void Act()
 {
     _actual = _target.ReadByte();
 }