本文整理汇总了C#中SftpClient.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# SftpClient.Dispose方法的具体用法?C# SftpClient.Dispose怎么用?C# SftpClient.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SftpClient
的用法示例。
在下文中一共展示了SftpClient.Dispose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Arrange
protected void Arrange()
{
_serviceFactoryMock = new Mock<IServiceFactory>(MockBehavior.Strict);
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
_sftpSessionMock = new Mock<ISftpSession>(MockBehavior.Strict);
_connectionInfo = new ConnectionInfo("host", "user", new NoneAuthenticationMethod("userauth"));
_operationTimeout = TimeSpan.FromSeconds(new Random().Next(1, 10));
_sftpClient = new SftpClient(_connectionInfo, false, _serviceFactoryMock.Object);
_sftpClient.OperationTimeout = _operationTimeout;
var sequence = new MockSequence();
_serviceFactoryMock.InSequence(sequence)
.Setup(p => p.CreateSession(_connectionInfo))
.Returns(_sessionMock.Object);
_sessionMock.InSequence(sequence).Setup(p => p.Connect());
_serviceFactoryMock.InSequence(sequence)
.Setup(p => p.CreateSftpSession(_sessionMock.Object, _operationTimeout, _connectionInfo.Encoding))
.Returns(_sftpSessionMock.Object);
_sftpSessionMock.InSequence(sequence).Setup(p => p.Connect());
_sessionMock.InSequence(sequence).Setup(p => p.OnDisconnecting());
_sftpSessionMock.InSequence(sequence).Setup(p => p.Disconnect());
_sftpSessionMock.InSequence(sequence).Setup(p => p.Dispose());
_sessionMock.InSequence(sequence).Setup(p => p.Disconnect());
_sessionMock.InSequence(sequence).Setup(p => p.Dispose());
_sftpClient.Connect();
_sftpClient.Dispose();
}