| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 | using System;using System.IO;using System.Threading.Tasks;using Microsoft.VisualStudio.TestTools.UnitTesting;using Renci.SshNet.Sftp;namespace Renci.SshNet.Tests.Classes.Sftp{    [TestClass]    public class SftpFileStreamTest_OpenAsync_FileAccessInvalid : SftpFileStreamAsyncTestBase    {        private Random _random;        private string _path;        private FileMode _fileMode;        private FileAccess _fileAccess;        private int _bufferSize;        private ArgumentOutOfRangeException _actualException;        protected override void SetupData()        {            base.SetupData();            _random = new Random();            _path = _random.Next().ToString();            _fileMode = FileMode.Open;            _fileAccess = 0;            _bufferSize = _random.Next(5, 1000);        }        protected override void SetupMocks()        {        }        protected override async Task ActAsync()        {            try            {                await SftpFileStream.OpenAsync(SftpSessionMock.Object, _path, _fileMode, _fileAccess, _bufferSize, default);                Assert.Fail();            }            catch (ArgumentOutOfRangeException ex)            {                _actualException = ex;            }        }        [TestMethod]        public void CtorShouldHaveThrownArgumentException()        {            Assert.IsNotNull(_actualException);            Assert.IsNull(_actualException.InnerException);            Assert.AreEqual("access", _actualException.ParamName);        }    }}
 |