Round 2 of analyzer fixes and general cleanup. (#1132)

This commit is contained in:
Gert Driesen
2023-05-29 17:16:08 +02:00
committed by GitHub
parent 3ecbd1071d
commit c04cdbcb97
365 changed files with 5146 additions and 4206 deletions
+11
View File
@@ -535,6 +535,11 @@ dotnet_diagnostic.IDE0045.severity = none
# Configured using 'dotnet_style_prefer_conditional_expression_over_return'
dotnet_diagnostic.IDE0046.severity = suggestion
# IDE0047: Remove unnecessary parentheses
#
# Removing "unnecessary" parentheses is not always a clear win for readability.
dotnet_diagnostic.IDE0047.severity = suggestion
# IDE0055: Fix formatting
#
# When enabled, diagnostics are reported for indented object initializers.
@@ -547,6 +552,12 @@ dotnet_diagnostic.IDE0046.severity = suggestion
# There are no settings to configure this correctly, unless https://github.com/dotnet/roslyn/issues/63256 (or similar) is ever implemented.
dotnet_diagnostic.IDE0055.severity = none
# IDE0130: Namespace does not match folder structure
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0130
#
# TODO: Remove when https://github.com/sshnet/SSH.NET/issues/1129 is fixed
dotnet_diagnostic.IDE0130.severity = none
# IDE0270: Null check can be simplified
#
# var inputPath = originalDossierPathList.Find(x => x.id == updatedPath.id);
-2
View File
@@ -9,10 +9,8 @@
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)src\Renci.SshNet.snk</AssemblyOriginatorKeyFile>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<LangVersion>latest</LangVersion>
<!--
<WarningLevel>9999</WarningLevel>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
-->
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>
+32
View File
@@ -0,0 +1,32 @@
[*.cs]
#### SYSLIB diagnostics ####
# SYSLIB1045: Use 'GeneratedRegexAttribute' to generate the regular expression implementation at compile-time
#
# TODO: Remove this when https://github.com/sshnet/SSH.NET/issues/1131 is implemented.
dotnet_diagnostic.SYSLIB1045.severity = none
### StyleCop Analyzers rules ###
#### .NET Compiler Platform analysers rules ####
# IDE0007: Use var instead of explicit type
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0007
dotnet_diagnostic.IDE0007.severity = suggestion
# IDE0028: Use collection initializers
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0028
dotnet_diagnostic.IDE0028.severity = suggestion
# IDE0058: Remove unnecessary expression value
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0058
dotnet_diagnostic.IDE0058.severity = suggestion
# IDE0059: Remove unnecessary value assignment
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0059
dotnet_diagnostic.IDE0059.severity = suggestion
# IDE0230: Use UTF-8 string literal
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0230
dotnet_diagnostic.IDE0230.severity = suggestion
@@ -6,15 +6,15 @@ namespace Renci.SshNet.Tests.Classes
{
public abstract class BaseClientTestBase : TripleATestBase
{
internal Mock<IServiceFactory> _serviceFactoryMock { get; private set; }
internal Mock<ISocketFactory> _socketFactoryMock { get; private set; }
internal Mock<ISession> _sessionMock { get; private set; }
internal Mock<IServiceFactory> ServiceFactoryMock { get; private set; }
internal Mock<ISocketFactory> SocketFactoryMock { get; private set; }
internal Mock<ISession> SessionMock { get; private set; }
protected virtual void CreateMocks()
{
_serviceFactoryMock = new Mock<IServiceFactory>(MockBehavior.Strict);
_socketFactoryMock = new Mock<ISocketFactory>(MockBehavior.Strict);
_sessionMock = new Mock<ISession>(MockBehavior.Strict);
ServiceFactoryMock = new Mock<IServiceFactory>(MockBehavior.Strict);
SocketFactoryMock = new Mock<ISocketFactory>(MockBehavior.Strict);
SessionMock = new Mock<ISession>(MockBehavior.Strict);
}
protected virtual void SetupData()
@@ -24,20 +24,20 @@ namespace Renci.SshNet.Tests.Classes
protected override void SetupMocks()
{
_serviceFactoryMock.Setup(p => p.CreateSocketFactory())
.Returns(_socketFactoryMock.Object);
_serviceFactoryMock.Setup(p => p.CreateSession(_connectionInfo, _socketFactoryMock.Object))
.Returns(_sessionMock.Object);
_sessionMock.Setup(p => p.Connect());
_sessionMock.Setup(p => p.Dispose());
ServiceFactoryMock.Setup(p => p.CreateSocketFactory())
.Returns(SocketFactoryMock.Object);
ServiceFactoryMock.Setup(p => p.CreateSession(_connectionInfo, SocketFactoryMock.Object))
.Returns(SessionMock.Object);
SessionMock.Setup(p => p.Connect());
SessionMock.Setup(p => p.Dispose());
}
protected override void TearDown()
{
if (_client != null)
{
_sessionMock.Setup(p => p.OnDisconnecting());
_sessionMock.Setup(p => p.Dispose());
SessionMock.Setup(p => p.OnDisconnecting());
SessionMock.Setup(p => p.Dispose());
_client.Dispose();
}
}
@@ -46,7 +46,7 @@ namespace Renci.SshNet.Tests.Classes
{
base.Arrange();
_client = new MyClient(_connectionInfo, false, _serviceFactoryMock.Object)
_client = new MyClient(_connectionInfo, false, ServiceFactoryMock.Object)
{
OnConnectedException = _onConnectException
};
@@ -75,26 +75,26 @@ namespace Renci.SshNet.Tests.Classes
[TestMethod]
public void CreateSocketFactoryOnServiceFactoryShouldBeInvokedOnce()
{
_serviceFactoryMock.Verify(p => p.CreateSocketFactory(), Times.Once);
ServiceFactoryMock.Verify(p => p.CreateSocketFactory(), Times.Once);
}
[TestMethod]
public void CreateSessionOnServiceFactoryShouldBeInvokedOnce()
{
_serviceFactoryMock.Verify(p => p.CreateSession(_connectionInfo, _socketFactoryMock.Object),
ServiceFactoryMock.Verify(p => p.CreateSession(_connectionInfo, SocketFactoryMock.Object),
Times.Once);
}
[TestMethod]
public void ConnectOnSessionShouldBeInvokedOnce()
{
_sessionMock.Verify(p => p.Connect(), Times.Once);
SessionMock.Verify(p => p.Connect(), Times.Once);
}
[TestMethod]
public void DisposeOnSessionShouldBeInvokedOnce()
{
_sessionMock.Verify(p => p.Dispose(), Times.Once);
SessionMock.Verify(p => p.Dispose(), Times.Once);
}
[TestMethod]
@@ -104,7 +104,7 @@ namespace Renci.SshNet.Tests.Classes
_client.ErrorOccurred += (sender, args) => Interlocked.Increment(ref errorOccurredSignalCount);
_sessionMock.Raise(p => p.ErrorOccured += null, new ExceptionEventArgs(new Exception()));
SessionMock.Raise(p => p.ErrorOccured += null, new ExceptionEventArgs(new Exception()));
Assert.AreEqual(0, errorOccurredSignalCount);
}
@@ -116,7 +116,7 @@ namespace Renci.SshNet.Tests.Classes
_client.HostKeyReceived += (sender, args) => Interlocked.Increment(ref hostKeyReceivedSignalCount);
_sessionMock.Raise(p => p.HostKeyReceived += null, new HostKeyEventArgs(GetKeyHostAlgorithm()));
SessionMock.Raise(p => p.HostKeyReceived += null, new HostKeyEventArgs(GetKeyHostAlgorithm()));
Assert.AreEqual(0, hostKeyReceivedSignalCount);
}
@@ -1,8 +1,10 @@
using System;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Connection;
using Renci.SshNet.Messages.Transport;
namespace Renci.SshNet.Tests.Classes
@@ -24,22 +26,23 @@ namespace Renci.SshNet.Tests.Classes
protected override void SetupMocks()
{
_serviceFactoryMock.Setup(p => p.CreateSocketFactory())
.Returns(_socketFactoryMock.Object);
_serviceFactoryMock.Setup(p => p.CreateSession(_connectionInfo, _socketFactoryMock.Object))
.Returns(_sessionMock.Object);
_sessionMock.Setup(p => p.Connect());
_sessionMock.Setup(p => p.IsConnected).Returns(true);
_sessionMock.Setup(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()))
.Returns(true)
.Callback(() => Interlocked.Increment(ref _keepAliveCount));
_ = ServiceFactoryMock.Setup(p => p.CreateSocketFactory())
.Returns(SocketFactoryMock.Object);
_ = ServiceFactoryMock.Setup(p => p.CreateSession(_connectionInfo, SocketFactoryMock.Object))
.Returns(SessionMock.Object);
_ = SessionMock.Setup(p => p.Connect());
_ = SessionMock.Setup(p => p.IsConnected)
.Returns(true);
_ = SessionMock.Setup(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()))
.Returns(true)
.Callback(() => Interlocked.Increment(ref _keepAliveCount));
}
protected override void Arrange()
{
base.Arrange();
_client = new MyClient(_connectionInfo, false, _serviceFactoryMock.Object);
_client = new MyClient(_connectionInfo, false, ServiceFactoryMock.Object);
_client.Connect();
_client.KeepAliveInterval = _keepAliveInterval;
}
@@ -48,8 +51,8 @@ namespace Renci.SshNet.Tests.Classes
{
if (_client != null)
{
_sessionMock.Setup(p => p.OnDisconnecting());
_sessionMock.Setup(p => p.Dispose());
SessionMock.Setup(p => p.OnDisconnecting());
SessionMock.Setup(p => p.Dispose());
_client.Dispose();
}
}
@@ -72,25 +75,25 @@ namespace Renci.SshNet.Tests.Classes
[TestMethod]
public void CreateSocketFactoryOnServiceFactoryShouldBeInvokedOnce()
{
_serviceFactoryMock.Verify(p => p.CreateSocketFactory(), Times.Once);
ServiceFactoryMock.Verify(p => p.CreateSocketFactory(), Times.Once);
}
[TestMethod]
public void CreateSessionOnServiceFactoryShouldBeInvokedOnce()
{
_serviceFactoryMock.Verify(p => p.CreateSession(_connectionInfo, _socketFactoryMock.Object), Times.Once);
ServiceFactoryMock.Verify(p => p.CreateSession(_connectionInfo, SocketFactoryMock.Object), Times.Once);
}
[TestMethod]
public void ConnectOnSessionShouldBeInvokedOnce()
{
_sessionMock.Verify(p => p.Connect(), Times.Once);
SessionMock.Verify(p => p.Connect(), Times.Once);
}
[TestMethod]
public void IsConnectedOnSessionShouldBeInvokedOnce()
{
_sessionMock.Verify(p => p.IsConnected, Times.Once);
SessionMock.Verify(p => p.IsConnected, Times.Once);
}
[TestMethod]
@@ -99,7 +102,7 @@ namespace Renci.SshNet.Tests.Classes
// allow keep-alive to be sent once
Thread.Sleep(100);
_sessionMock.Verify(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()), Times.Exactly(1));
SessionMock.Verify(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()), Times.Exactly(1));
}
private class MyClient : BaseClient
@@ -23,13 +23,13 @@ namespace Renci.SshNet.Tests.Classes
protected override void SetupMocks()
{
_serviceFactoryMock.Setup(p => p.CreateSocketFactory())
.Returns(_socketFactoryMock.Object);
_serviceFactoryMock.Setup(p => p.CreateSession(_connectionInfo, _socketFactoryMock.Object))
.Returns(_sessionMock.Object);
_sessionMock.Setup(p => p.Connect());
_sessionMock.Setup(p => p.IsConnected).Returns(true);
_sessionMock.Setup(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()))
ServiceFactoryMock.Setup(p => p.CreateSocketFactory())
.Returns(SocketFactoryMock.Object);
ServiceFactoryMock.Setup(p => p.CreateSession(_connectionInfo, SocketFactoryMock.Object))
.Returns(SessionMock.Object);
SessionMock.Setup(p => p.Connect());
SessionMock.Setup(p => p.IsConnected).Returns(true);
SessionMock.Setup(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()))
.Returns(true)
.Callback(() => Interlocked.Increment(ref _keepAliveCount));
}
@@ -38,7 +38,7 @@ namespace Renci.SshNet.Tests.Classes
{
base.Arrange();
_client = new MyClient(_connectionInfo, false, _serviceFactoryMock.Object);
_client = new MyClient(_connectionInfo, false, ServiceFactoryMock.Object);
_client.Connect();
}
@@ -46,8 +46,8 @@ namespace Renci.SshNet.Tests.Classes
{
if (_client != null)
{
_sessionMock.Setup(p => p.OnDisconnecting());
_sessionMock.Setup(p => p.Dispose());
SessionMock.Setup(p => p.OnDisconnecting());
SessionMock.Setup(p => p.Dispose());
_client.Dispose();
}
}
@@ -74,32 +74,32 @@ namespace Renci.SshNet.Tests.Classes
[TestMethod]
public void CreateSocketFactoryOnServiceFactoryShouldBeInvokedOnce()
{
_serviceFactoryMock.Verify(p => p.CreateSocketFactory(), Times.Once);
ServiceFactoryMock.Verify(p => p.CreateSocketFactory(), Times.Once);
}
[TestMethod]
public void CreateSessionOnServiceFactoryShouldBeInvokedOnce()
{
_serviceFactoryMock.Verify(p => p.CreateSession(_connectionInfo, _socketFactoryMock.Object),
ServiceFactoryMock.Verify(p => p.CreateSession(_connectionInfo, SocketFactoryMock.Object),
Times.Once);
}
[TestMethod]
public void ConnectOnSessionShouldBeInvokedOnce()
{
_sessionMock.Verify(p => p.Connect(), Times.Once);
SessionMock.Verify(p => p.Connect(), Times.Once);
}
[TestMethod]
public void IsConnectedOnSessionShouldBeInvokedOnce()
{
_sessionMock.Verify(p => p.IsConnected, Times.Once);
SessionMock.Verify(p => p.IsConnected, Times.Once);
}
[TestMethod]
public void SendMessageOnSessionShouldBeInvokedThreeTimes()
{
_sessionMock.Verify(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()), Times.Exactly(3));
SessionMock.Verify(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()), Times.Exactly(3));
}
private class MyClient : BaseClient
@@ -24,15 +24,15 @@ namespace Renci.SshNet.Tests.Classes
{
_mockSequence = new MockSequence();
_serviceFactoryMock.InSequence(_mockSequence)
ServiceFactoryMock.InSequence(_mockSequence)
.Setup(p => p.CreateSocketFactory())
.Returns(_socketFactoryMock.Object);
_serviceFactoryMock.InSequence(_mockSequence)
.Setup(p => p.CreateSession(_connectionInfo, _socketFactoryMock.Object))
.Returns(_sessionMock.Object);
_sessionMock.InSequence(_mockSequence)
.Returns(SocketFactoryMock.Object);
ServiceFactoryMock.InSequence(_mockSequence)
.Setup(p => p.CreateSession(_connectionInfo, SocketFactoryMock.Object))
.Returns(SessionMock.Object);
SessionMock.InSequence(_mockSequence)
.Setup(p => p.Connect());
_sessionMock.InSequence(_mockSequence)
SessionMock.InSequence(_mockSequence)
.Setup(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()))
.Returns(true)
.Callback(() =>
@@ -46,7 +46,7 @@ namespace Renci.SshNet.Tests.Classes
{
base.Arrange();
_client = new MyClient(_connectionInfo, false, _serviceFactoryMock.Object)
_client = new MyClient(_connectionInfo, false, ServiceFactoryMock.Object)
{
KeepAliveInterval = TimeSpan.FromMilliseconds(50d)
};
@@ -57,8 +57,8 @@ namespace Renci.SshNet.Tests.Classes
{
if (_client != null)
{
_sessionMock.InSequence(_mockSequence).Setup(p => p.OnDisconnecting());
_sessionMock.InSequence(_mockSequence).Setup(p => p.Dispose());
SessionMock.InSequence(_mockSequence).Setup(p => p.OnDisconnecting());
SessionMock.InSequence(_mockSequence).Setup(p => p.Dispose());
_client.Dispose();
}
}
@@ -79,7 +79,7 @@ namespace Renci.SshNet.Tests.Classes
[TestMethod]
public void SendMessageOnSessionShouldBeInvokedOnce()
{
_sessionMock.Verify(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()), Times.Once);
SessionMock.Verify(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()), Times.Once);
}
private class MyClient : BaseClient
@@ -29,22 +29,22 @@ namespace Renci.SshNet.Tests.Classes
{
var sequence = new MockSequence();
_serviceFactoryMock.InSequence(sequence)
ServiceFactoryMock.InSequence(sequence)
.Setup(p => p.CreateSocketFactory())
.Returns(_socketFactoryMock.Object);
_serviceFactoryMock.InSequence(sequence)
.Setup(p => p.CreateSession(_connectionInfo, _socketFactoryMock.Object))
.Returns(_sessionMock.Object);
_sessionMock.InSequence(sequence)
.Returns(SocketFactoryMock.Object);
ServiceFactoryMock.InSequence(sequence)
.Setup(p => p.CreateSession(_connectionInfo, SocketFactoryMock.Object))
.Returns(SessionMock.Object);
SessionMock.InSequence(sequence)
.Setup(p => p.Connect());
_sessionMock.InSequence(sequence)
SessionMock.InSequence(sequence)
.Setup(p => p.OnDisconnecting());
_sessionMock.InSequence(sequence)
SessionMock.InSequence(sequence)
.Setup(p => p.Dispose());
_serviceFactoryMock.InSequence(sequence)
ServiceFactoryMock.InSequence(sequence)
.Setup(p => p.CreateSocketFactory())
.Returns(_socketFactory2Mock.Object);
_serviceFactoryMock.InSequence(sequence)
ServiceFactoryMock.InSequence(sequence)
.Setup(p => p.CreateSession(_connectionInfo, _socketFactory2Mock.Object))
.Returns(_session2Mock.Object);
_session2Mock.InSequence(sequence)
@@ -55,7 +55,7 @@ namespace Renci.SshNet.Tests.Classes
{
base.Arrange();
_client = new MyClient(_connectionInfo, false, _serviceFactoryMock.Object);
_client = new MyClient(_connectionInfo, false, ServiceFactoryMock.Object);
_client.Connect();
_client.Disconnect();
}
@@ -78,22 +78,22 @@ namespace Renci.SshNet.Tests.Classes
[TestMethod]
public void CreateSocketFactoryOnServiceFactoryShouldBeInvokedTwic()
{
_serviceFactoryMock.Verify(p => p.CreateSocketFactory(), Times.Exactly(2));
ServiceFactoryMock.Verify(p => p.CreateSocketFactory(), Times.Exactly(2));
}
[TestMethod]
public void CreateSessionOnServiceFactoryShouldBeInvokedTwice()
{
_serviceFactoryMock.Verify(p => p.CreateSession(_connectionInfo, _socketFactoryMock.Object),
ServiceFactoryMock.Verify(p => p.CreateSession(_connectionInfo, SocketFactoryMock.Object),
Times.Once);
_serviceFactoryMock.Verify(p => p.CreateSession(_connectionInfo, _socketFactory2Mock.Object),
ServiceFactoryMock.Verify(p => p.CreateSession(_connectionInfo, _socketFactory2Mock.Object),
Times.Once);
}
[TestMethod]
public void ConnectOnSessionShouldBeInvokedTwice()
{
_sessionMock.Verify(p => p.Connect(), Times.Once);
SessionMock.Verify(p => p.Connect(), Times.Once);
_session2Mock.Verify(p => p.Connect(), Times.Once);
}
@@ -21,13 +21,13 @@ namespace Renci.SshNet.Tests.Classes
protected override void SetupMocks()
{
_serviceFactoryMock.Setup(p => p.CreateSocketFactory())
.Returns(_socketFactoryMock.Object);
_serviceFactoryMock.Setup(p => p.CreateSession(_connectionInfo, _socketFactoryMock.Object))
.Returns(_sessionMock.Object);
_sessionMock.Setup(p => p.Connect());
_sessionMock.Setup(p => p.IsConnected).Returns(false);
_sessionMock.Setup(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()))
ServiceFactoryMock.Setup(p => p.CreateSocketFactory())
.Returns(SocketFactoryMock.Object);
ServiceFactoryMock.Setup(p => p.CreateSession(_connectionInfo, SocketFactoryMock.Object))
.Returns(SessionMock.Object);
SessionMock.Setup(p => p.Connect());
SessionMock.Setup(p => p.IsConnected).Returns(false);
SessionMock.Setup(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()))
.Returns(true);
}
@@ -35,7 +35,7 @@ namespace Renci.SshNet.Tests.Classes
{
base.Arrange();
_client = new MyClient(_connectionInfo, false, _serviceFactoryMock.Object);
_client = new MyClient(_connectionInfo, false, ServiceFactoryMock.Object);
_client.Connect();
}
@@ -43,8 +43,8 @@ namespace Renci.SshNet.Tests.Classes
{
if (_client != null)
{
_sessionMock.Setup(p => p.OnDisconnecting());
_sessionMock.Setup(p => p.Dispose());
SessionMock.Setup(p => p.OnDisconnecting());
SessionMock.Setup(p => p.Dispose());
_client.Dispose();
}
}
@@ -66,32 +66,32 @@ namespace Renci.SshNet.Tests.Classes
[TestMethod]
public void CreateSocketFactoryOnServiceFactoryShouldBeInvokedOnce()
{
_serviceFactoryMock.Verify(p => p.CreateSocketFactory(), Times.Once);
ServiceFactoryMock.Verify(p => p.CreateSocketFactory(), Times.Once);
}
[TestMethod]
public void CreateSessionOnServiceFactoryShouldBeInvokedOnce()
{
_serviceFactoryMock.Verify(p => p.CreateSession(_connectionInfo, _socketFactoryMock.Object),
ServiceFactoryMock.Verify(p => p.CreateSession(_connectionInfo, SocketFactoryMock.Object),
Times.Once);
}
[TestMethod]
public void ConnectOnSessionShouldBeInvokedOnce()
{
_sessionMock.Verify(p => p.Connect(), Times.Once);
SessionMock.Verify(p => p.Connect(), Times.Once);
}
[TestMethod]
public void IsConnectedOnSessionShouldBeInvokedOnce()
{
_sessionMock.Verify(p => p.IsConnected, Times.Once);
SessionMock.Verify(p => p.IsConnected, Times.Once);
}
[TestMethod]
public void SendMessageOnSessionShouldNeverBeInvoked()
{
_sessionMock.Verify(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()), Times.Never);
SessionMock.Verify(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()), Times.Never);
}
private class MyClient : BaseClient
@@ -25,15 +25,15 @@ namespace Renci.SshNet.Tests.Classes
{
base.Arrange();
_client = new MyClient(_connectionInfo, false, _serviceFactoryMock.Object);
_client = new MyClient(_connectionInfo, false, ServiceFactoryMock.Object);
}
protected override void TearDown()
{
if (_client != null)
{
_sessionMock.Setup(p => p.OnDisconnecting());
_sessionMock.Setup(p => p.Dispose());
SessionMock.Setup(p => p.OnDisconnecting());
SessionMock.Setup(p => p.Dispose());
_client.Dispose();
}
}
@@ -55,12 +55,12 @@ namespace Renci.SshNet.Tests.Classes
[TestMethod]
public void ConnectShouldActivateKeepAliveIfSessionIs()
{
_serviceFactoryMock.Setup(p => p.CreateSocketFactory())
.Returns(_socketFactoryMock.Object);
_serviceFactoryMock.Setup(p => p.CreateSession(_connectionInfo, _socketFactoryMock.Object))
.Returns(_sessionMock.Object);
_sessionMock.Setup(p => p.Connect());
_sessionMock.Setup(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()))
ServiceFactoryMock.Setup(p => p.CreateSocketFactory())
.Returns(SocketFactoryMock.Object);
ServiceFactoryMock.Setup(p => p.CreateSession(_connectionInfo, SocketFactoryMock.Object))
.Returns(SessionMock.Object);
SessionMock.Setup(p => p.Connect());
SessionMock.Setup(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()))
.Returns(true)
.Callback(() => Interlocked.Increment(ref _keepAliveCount));
@@ -70,7 +70,7 @@ namespace Renci.SshNet.Tests.Classes
Thread.Sleep(250);
// Exactly two keep-alives should be sent
_sessionMock.Verify(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()), Times.Exactly(2));
SessionMock.Verify(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()), Times.Exactly(2));
}
private class MyClient : BaseClient
@@ -3,8 +3,11 @@ using System.Globalization;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Channels;
using Renci.SshNet.Common;
using Renci.SshNet.Messages;
@@ -53,16 +56,17 @@ namespace Renci.SshNet.Tests.Classes.Channels
[TestMethod]
public void SocketShouldBeClosedAndBindShouldEndWhenForwardedPortSignalsClosingEvent()
{
_sessionMock.Setup(p => p.IsConnected).Returns(true);
_sessionMock.Setup(p => p.SendMessage(It.IsAny<ChannelOpenMessage>()))
.Callback<Message>(m => _sessionMock.Raise(p => p.ChannelOpenConfirmationReceived += null,
_ = _sessionMock.Setup(p => p.IsConnected)
.Returns(true);
_ = _sessionMock.Setup(p => p.SendMessage(It.IsAny<ChannelOpenMessage>()))
.Callback<Message>(m => _sessionMock.Raise(p => p.ChannelOpenConfirmationReceived += null,
new MessageEventArgs<ChannelOpenConfirmationMessage>(
new ChannelOpenConfirmationMessage(((ChannelOpenMessage) m).LocalChannelNumber,
_remoteWindowSize,
_remotePacketSize,
_remoteChannelNumber))));
_sessionMock.Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
.Callback<WaitHandle>(p => p.WaitOne(Session.Infinite));
_ = _sessionMock.Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
.Callback<WaitHandle>(p => p.WaitOne(Session.Infinite));
var localPortEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
using (var localPortListener = new AsyncSocketListener(localPortEndPoint))
@@ -108,16 +112,17 @@ namespace Renci.SshNet.Tests.Classes.Channels
[TestMethod]
public void SocketShouldBeClosedAndBindShouldEndWhenOnErrorOccurredIsInvoked()
{
_sessionMock.Setup(p => p.IsConnected).Returns(true);
_sessionMock.Setup(p => p.SendMessage(It.IsAny<ChannelOpenMessage>()))
.Callback<Message>(m => _sessionMock.Raise(p => p.ChannelOpenConfirmationReceived += null,
_ = _sessionMock.Setup(p => p.IsConnected)
.Returns(true);
_ = _sessionMock.Setup(p => p.SendMessage(It.IsAny<ChannelOpenMessage>()))
.Callback<Message>(m => _sessionMock.Raise(p => p.ChannelOpenConfirmationReceived += null,
new MessageEventArgs<ChannelOpenConfirmationMessage>(
new ChannelOpenConfirmationMessage(((ChannelOpenMessage) m).LocalChannelNumber,
_remoteWindowSize,
_remotePacketSize,
_remoteChannelNumber))));
_sessionMock.Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
.Callback<WaitHandle>(p => p.WaitOne(Session.Infinite));
_ = _sessionMock.Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
.Callback<WaitHandle>(p => p.WaitOne(Session.Infinite));
var localPortEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
using (var localPortListener = new AsyncSocketListener(localPortEndPoint))
@@ -166,46 +171,53 @@ namespace Renci.SshNet.Tests.Classes.Channels
{
var sequence = new MockSequence();
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
_sessionMock.InSequence(sequence)
.Setup(p => p.SendMessage(It.IsAny<ChannelOpenMessage>()))
.Callback<Message>(m => _sessionMock.Raise(p => p.ChannelOpenConfirmationReceived += null,
_ = _sessionMock.InSequence(sequence).Setup(p => p.IsConnected)
.Returns(true);
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.SendMessage(It.IsAny<ChannelOpenMessage>()))
.Callback<Message>(m => _sessionMock.Raise(p => p.ChannelOpenConfirmationReceived += null,
new MessageEventArgs<ChannelOpenConfirmationMessage>(
new ChannelOpenConfirmationMessage(((ChannelOpenMessage) m).LocalChannelNumber,
_remoteWindowSize,
_remotePacketSize,
_remoteChannelNumber))));
_sessionMock.InSequence(sequence)
.Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
.Callback<WaitHandle>(p => p.WaitOne(Session.Infinite));
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
_sessionMock.InSequence(sequence)
.Setup(p => p.TrySendMessage(It.IsAny<ChannelEofMessage>()))
.Returns(true)
.Callback<Message>(
m => new Thread(() =>
{
Thread.Sleep(50);
_sessionMock.Raise(s => s.ChannelEofReceived += null,
new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
}).Start());
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
_sessionMock.InSequence(sequence)
.Setup(p => p.TrySendMessage(It.IsAny<ChannelCloseMessage>()))
.Returns(true)
.Callback<Message>(
m => new Thread(() =>
{
Thread.Sleep(50);
_sessionMock.Raise(s => s.ChannelCloseReceived += null,
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
}).Start());
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
_connectionInfoMock.InSequence(sequence).Setup(p => p.ChannelCloseTimeout).Returns(_channelCloseTimeout);
_sessionMock.InSequence(sequence)
.Setup(p => p.TryWait(It.IsAny<EventWaitHandle>(), _channelCloseTimeout))
.Callback<WaitHandle, TimeSpan>((waitHandle, channelCloseTimeout) => waitHandle.WaitOne())
.Returns(WaitResult.Success);
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
.Callback<WaitHandle>(p => p.WaitOne(Session.Infinite));
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.IsConnected)
.Returns(true);
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.TrySendMessage(It.IsAny<ChannelEofMessage>()))
.Returns(true)
.Callback<Message>(m => new Thread(() =>
{
Thread.Sleep(50);
_sessionMock.Raise(s => s.ChannelEofReceived += null,
new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
}).Start());
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.IsConnected)
.Returns(true);
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.TrySendMessage(It.IsAny<ChannelCloseMessage>()))
.Returns(true)
.Callback<Message>(m => new Thread(() =>
{
Thread.Sleep(50);
_sessionMock.Raise(s => s.ChannelCloseReceived += null,
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
}).Start());
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.ConnectionInfo)
.Returns(_connectionInfoMock.Object);
_ = _connectionInfoMock.InSequence(sequence)
.Setup(p => p.ChannelCloseTimeout)
.Returns(_channelCloseTimeout);
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.TryWait(It.IsAny<EventWaitHandle>(), _channelCloseTimeout))
.Callback<WaitHandle, TimeSpan>((waitHandle, channelCloseTimeout) => waitHandle.WaitOne())
.Returns(WaitResult.Success);
var channelBindFinishedWaitHandle = new ManualResetEvent(false);
Socket handler = null;
@@ -217,26 +229,26 @@ namespace Renci.SshNet.Tests.Classes.Channels
localPortListener.Start();
localPortListener.Connected += socket =>
{
channel = new ChannelDirectTcpip(_sessionMock.Object,
_localChannelNumber,
_localWindowSize,
_localPacketSize);
channel.Open(_remoteHost, _port, _forwardedPortMock.Object, socket);
channel.Bind();
channel.Dispose();
{
channel = new ChannelDirectTcpip(_sessionMock.Object,
_localChannelNumber,
_localWindowSize,
_localPacketSize);
channel.Open(_remoteHost, _port, _forwardedPortMock.Object, socket);
channel.Bind();
channel.Dispose();
handler = socket;
handler = socket;
channelBindFinishedWaitHandle.Set();
};
_ = channelBindFinishedWaitHandle.Set();
};
var client = new Socket(localPortEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
client.Connect(localPortEndPoint);
client.Shutdown(SocketShutdown.Send);
Assert.IsFalse(client.Connected);
channelBindFinishedWaitHandle.WaitOne();
_ = channelBindFinishedWaitHandle.WaitOne();
Assert.IsNotNull(handler);
Assert.IsFalse(handler.Connected);
@@ -251,4 +263,4 @@ namespace Renci.SshNet.Tests.Classes.Channels
}
}
}
}
}
@@ -79,45 +79,53 @@ namespace Renci.SshNet.Tests.Classes.Channels
_forwardedPortMock = new Mock<IForwardedPort>(MockBehavior.Strict);
var sequence = new MockSequence();
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
_sessionMock.InSequence(sequence)
.Setup(p => p.SendMessage(It.Is<ChannelOpenMessage>(m => AssertExpectedMessage(m))));
_sessionMock.InSequence(sequence)
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
.Callback<WaitHandle>(
w =>
{
_sessionMock.Raise(
s => s.ChannelOpenConfirmationReceived += null,
new MessageEventArgs<ChannelOpenConfirmationMessage>(
new ChannelOpenConfirmationMessage(
_localChannelNumber,
_remoteWindowSize,
_remotePacketSize,
_remoteChannelNumber)));
w.WaitOne();
});
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
_sessionMock.InSequence(sequence)
.Setup(
p => p.TrySendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)))
.Returns(true);
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
_sessionMock.InSequence(sequence)
.Setup(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)))
.Returns(true);
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
_connectionInfoMock.InSequence(sequence).Setup(p => p.ChannelCloseTimeout).Returns(_channelCloseTimeout);
_sessionMock.InSequence(sequence)
.Setup(p => p.TryWait(It.IsAny<EventWaitHandle>(), _channelCloseTimeout))
.Callback<WaitHandle, TimeSpan>((waitHandle, channelCloseTimeout) =>
{
_sessionMock.Raise(
s => s.ChannelCloseReceived += null,
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
waitHandle.WaitOne();
})
.Returns(WaitResult.Success);
_ = _sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.SendMessage(It.Is<ChannelOpenMessage>(m => AssertExpectedMessage(m))));
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.WaitOnHandle(It.IsNotNull<WaitHandle>()))
.Callback<WaitHandle>(
w =>
{
_sessionMock.Raise(
s => s.ChannelOpenConfirmationReceived += null,
new MessageEventArgs<ChannelOpenConfirmationMessage>(
new ChannelOpenConfirmationMessage(
_localChannelNumber,
_remoteWindowSize,
_remotePacketSize,
_remoteChannelNumber)));
_ = w.WaitOne();
});
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.IsConnected)
.Returns(true);
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.TrySendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)))
.Returns(true);
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.IsConnected)
.Returns(true);
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)))
.Returns(true);
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.ConnectionInfo)
.Returns(_connectionInfoMock.Object);
_ = _connectionInfoMock.InSequence(sequence)
.Setup(p => p.ChannelCloseTimeout)
.Returns(_channelCloseTimeout);
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.TryWait(It.IsAny<EventWaitHandle>(), _channelCloseTimeout))
.Callback<WaitHandle, TimeSpan>((waitHandle, channelCloseTimeout) =>
{
_sessionMock.Raise(
s => s.ChannelCloseReceived += null,
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
_ = waitHandle.WaitOne();
})
.Returns(WaitResult.Success);
var localEndpoint = new IPEndPoint(IPAddress.Loopback, 8122);
_listener = new AsyncSocketListener(localEndpoint);
@@ -138,7 +146,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
}
finally
{
_channelBindFinishedWaitHandle.Set();
_ = _channelBindFinishedWaitHandle.Set();
}
};
_listener.Start();
@@ -154,7 +162,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
if (bytesReceived == 0)
{
_client.Shutdown(SocketShutdown.Send);
_clientReceivedFinishedWaitHandle.Set();
_ = _clientReceivedFinishedWaitHandle.Set();
}
}
);
@@ -166,17 +174,14 @@ namespace Renci.SshNet.Tests.Classes.Channels
private void Act()
{
if (_channel != null)
{
_channel.Dispose();
}
_channel?.Dispose();
}
[TestMethod]
public void BindShouldHaveFinishedWithoutException()
{
Assert.IsTrue(_channelBindFinishedWaitHandle.WaitOne(0));
Assert.IsNull(_channelException, _channelException != null ? _channelException.ToString() : null);
Assert.IsNull(_channelException, _channelException?.ToString());
}
[TestMethod]
@@ -206,29 +211,54 @@ namespace Renci.SshNet.Tests.Classes.Channels
private bool AssertExpectedMessage(ChannelOpenMessage channelOpenMessage)
{
if (channelOpenMessage == null)
{
return false;
}
if (channelOpenMessage.LocalChannelNumber != _localChannelNumber)
{
return false;
}
if (channelOpenMessage.InitialWindowSize != _localWindowSize)
{
return false;
}
if (channelOpenMessage.MaximumPacketSize != _localPacketSize)
{
return false;
}
var directTcpipChannelInfo = channelOpenMessage.Info as DirectTcpipChannelInfo;
if (directTcpipChannelInfo == null)
if (channelOpenMessage.Info is not DirectTcpipChannelInfo directTcpipChannelInfo)
{
return false;
}
if (directTcpipChannelInfo.HostToConnect != _remoteHost)
{
return false;
if (directTcpipChannelInfo.PortToConnect != _port)
return false;
}
var clientEndpoint = _client.LocalEndPoint as IPEndPoint;
if (clientEndpoint == null)
if (directTcpipChannelInfo.PortToConnect != _port)
{
return false;
}
if (_client.LocalEndPoint is not IPEndPoint clientEndpoint)
{
return false;
}
if (directTcpipChannelInfo.OriginatorAddress != clientEndpoint.Address.ToString())
{
return false;
}
if (directTcpipChannelInfo.OriginatorPort != clientEndpoint.Port)
{
return false;
}
return true;
}
@@ -1,11 +1,13 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Channels;
using Renci.SshNet.Messages.Connection;
using Renci.SshNet.Tests.Common;
@@ -53,10 +55,10 @@ namespace Renci.SshNet.Tests.Classes.Channels
if (_channelThread != null)
{
if (_channelThread.IsAlive)
_channelThread.Abort();
_channelThread.Join();
_channelThread = null;
}
if (_channel != null)
{
_channel.Dispose();
@@ -87,56 +89,63 @@ namespace Renci.SshNet.Tests.Classes.Channels
_forwardedPortMock = new Mock<IForwardedPort>(MockBehavior.Strict);
var sequence = new MockSequence();
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
_connectionInfoMock.InSequence(sequence).Setup(p => p.Timeout).Returns(_connectionInfoTimeout);
_sessionMock.InSequence(sequence).Setup(
p => p.SendMessage(
It.Is<ChannelOpenConfirmationMessage>(
m => m.LocalChannelNumber == _remoteChannelNumber
&&
m.InitialWindowSize == _localWindowSize
&&
m.MaximumPacketSize == _localPacketSize
&&
m.RemoteChannelNumber == _localChannelNumber)
));
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
_sessionMock.InSequence(sequence)
.Setup(
p => p.TrySendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)))
.Returns(true);
_sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
_sessionMock.InSequence(sequence)
.Setup(
p => p.TrySendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)))
.Returns(true);
_sessionMock.InSequence(sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
_connectionInfoMock.InSequence(sequence).Setup(p => p.ChannelCloseTimeout).Returns(_channelCloseTimeout);
_sessionMock.InSequence(sequence)
.Setup(p => p.TryWait(It.IsAny<EventWaitHandle>(), _channelCloseTimeout))
.Callback<WaitHandle, TimeSpan>((waitHandle, channelCloseTimeout) =>
{
_sessionMock.Raise(
s => s.ChannelCloseReceived += null,
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
waitHandle.WaitOne();
})
.Returns(WaitResult.Success);
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.IsConnected)
.Returns(true);
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.ConnectionInfo)
.Returns(_connectionInfoMock.Object);
_ = _connectionInfoMock.InSequence(sequence)
.Setup(p => p.Timeout)
.Returns(_connectionInfoTimeout);
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.SendMessage(It.Is<ChannelOpenConfirmationMessage>(m =>
m.LocalChannelNumber == _remoteChannelNumber &&
m.InitialWindowSize == _localWindowSize &&
m.MaximumPacketSize == _localPacketSize &&
m.RemoteChannelNumber == _localChannelNumber)));
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.IsConnected)
.Returns(true);
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.TrySendMessage(It.Is<ChannelEofMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)))
.Returns(true);
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.IsConnected)
.Returns(true);
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(m => m.LocalChannelNumber == _remoteChannelNumber)))
.Returns(true);
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.ConnectionInfo)
.Returns(_connectionInfoMock.Object);
_ = _connectionInfoMock.InSequence(sequence)
.Setup(p => p.ChannelCloseTimeout)
.Returns(_channelCloseTimeout);
_ = _sessionMock.InSequence(sequence)
.Setup(p => p.TryWait(It.IsAny<EventWaitHandle>(), _channelCloseTimeout))
.Callback<WaitHandle, TimeSpan>((waitHandle, channelCloseTimeout) =>
{
_sessionMock.Raise(
s => s.ChannelCloseReceived += null,
new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
_ = waitHandle.WaitOne();
})
.Returns(WaitResult.Success);
_remoteListener = new AsyncSocketListener(_remoteEndpoint);
_remoteListener.Connected += socket => _connectedRegister.Add(socket);
_remoteListener.Disconnected += socket => _disconnectedRegister.Add(socket);
_remoteListener.Connected += _connectedRegister.Add;
_remoteListener.Disconnected += _disconnectedRegister.Add;
_remoteListener.Start();
_channel = new ChannelForwardedTcpip(
_sessionMock.Object,
_localChannelNumber,
_localWindowSize,
_localPacketSize,
_remoteChannelNumber,
_remoteWindowSize,
_remotePacketSize);
_channel = new ChannelForwardedTcpip(_sessionMock.Object,
_localChannelNumber,
_localWindowSize,
_localPacketSize,
_remoteChannelNumber,
_remoteWindowSize,
_remotePacketSize);
_channelThread = new Thread(() =>
{
@@ -150,7 +159,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
}
finally
{
_channelBindFinishedWaitHandle.Set();
_ = _channelBindFinishedWaitHandle.Set();
}
});
_channelThread.Start();
@@ -175,7 +184,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
[TestMethod]
public void BindShouldHaveFinishedWithoutException()
{
Assert.IsNull(_channelException, _channelException != null ? _channelException.ToString() : null);
Assert.IsNull(_channelException, _channelException?.ToString());
Assert.IsTrue(_channelBindFinishedWaitHandle.WaitOne(0));
}
@@ -197,4 +206,4 @@ namespace Renci.SshNet.Tests.Classes.Channels
Assert.IsFalse(_channel.IsOpen);
}
}
}
}
@@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Channels;
using Renci.SshNet.Common;
using Renci.SshNet.Messages.Connection;
@@ -144,4 +147,4 @@ namespace Renci.SshNet.Tests.Classes.Channels
Assert.IsFalse(_channel.IsOpen);
}
}
}
}
@@ -54,7 +54,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
public void InitializeRemoteChannelInfo(uint remoteChannelNumber, uint remoteWindowSize, uint remotePacketSize)
{
base.InitializeRemoteInfo(remoteChannelNumber, remoteWindowSize, remotePacketSize);
InitializeRemoteInfo(remoteChannelNumber, remoteWindowSize, remotePacketSize);
}
protected override void OnClose()
@@ -62,7 +62,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
base.OnClose();
if (OnCloseException != null)
{
throw OnCloseException;
}
}
protected override void OnData(byte[] data)
@@ -70,7 +72,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
base.OnData(data);
if (OnDataException != null)
{
throw OnDataException;
}
}
protected override void OnDisconnected()
@@ -78,7 +82,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
base.OnDisconnected();
if (OnDisconnectedException != null)
{
throw OnDisconnectedException;
}
}
protected override void OnEof()
@@ -86,7 +92,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
base.OnEof();
if (OnEofException != null)
{
throw OnEofException;
}
}
protected override void OnExtendedData(byte[] data, uint dataTypeCode)
@@ -94,7 +102,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
base.OnExtendedData(data, dataTypeCode);
if (OnExtendedDataException != null)
{
throw OnExtendedDataException;
}
}
protected override void OnErrorOccured(Exception exp)
@@ -102,7 +112,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
OnErrorOccurredInvocations.Add(exp);
if (OnErrorOccurredException != null)
{
throw OnErrorOccurredException;
}
}
protected override void OnFailure()
@@ -110,7 +122,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
base.OnFailure();
if (OnFailureException != null)
{
throw OnFailureException;
}
}
protected override void OnRequest(RequestInfo info)
@@ -118,7 +132,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
base.OnRequest(info);
if (OnRequestException != null)
{
throw OnRequestException;
}
}
protected override void OnSuccess()
@@ -126,7 +142,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
base.OnSuccess();
if (OnSuccessException != null)
{
throw OnSuccessException;
}
}
protected override void OnWindowAdjust(uint bytesToAdd)
@@ -134,7 +152,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
base.OnWindowAdjust(bytesToAdd);
if (OnWindowAdjustException != null)
{
throw OnWindowAdjustException;
}
}
}
}
@@ -94,12 +94,10 @@ namespace Renci.SshNet.Tests.Classes.Channels
_channelClosedReceived = null;
}
if (_raiseChannelCloseReceivedThread != null && _raiseChannelCloseReceivedThread.IsAlive)
if (_raiseChannelCloseReceivedThread != null)
{
if (!_raiseChannelCloseReceivedThread.Join(1000))
{
_raiseChannelCloseReceivedThread.Abort();
}
_raiseChannelCloseReceivedThread.Join();
_raiseChannelCloseReceivedThread = null;
}
if (_channelClosedEventHandlerCompleted != null)
@@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Messages.Connection;
@@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Messages.Connection;
@@ -61,4 +62,4 @@ namespace Renci.SshNet.Tests.Classes.Channels
Assert.AreSame(_onDataException, _channel.OnErrorOccurredInvocations[0]);
}
}
}
}
@@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Messages.Connection;
@@ -69,4 +70,4 @@ namespace Renci.SshNet.Tests.Classes.Channels
Assert.AreSame(_onEofException, _channel.OnErrorOccurredInvocations[0]);
}
}
}
}
@@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Messages.Connection;
@@ -61,4 +62,4 @@ namespace Renci.SshNet.Tests.Classes.Channels
Assert.AreSame(_onExtendedDataException, _channel.OnErrorOccurredInvocations[0]);
}
}
}
}
@@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Messages.Connection;
@@ -61,4 +62,4 @@ namespace Renci.SshNet.Tests.Classes.Channels
Assert.AreSame(_onFailureException, _channel.OnErrorOccurredInvocations[0]);
}
}
}
}
@@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Messages.Connection;
@@ -32,8 +33,8 @@ namespace Renci.SshNet.Tests.Classes.Channels
protected override void SetupMocks()
{
SessionMock.Setup(p => p.ConnectionInfo)
.Returns(new ConnectionInfo("host", "user", new PasswordAuthenticationMethod("user", "password")));
_ = SessionMock.Setup(p => p.ConnectionInfo)
.Returns(new ConnectionInfo("host", "user", new PasswordAuthenticationMethod("user", "password")));
}
protected override void Arrange()
@@ -65,4 +66,4 @@ namespace Renci.SshNet.Tests.Classes.Channels
Assert.AreSame(_onRequestException, _channel.OnErrorOccurredInvocations[0]);
}
}
}
}
@@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Messages.Connection;
@@ -61,4 +62,4 @@ namespace Renci.SshNet.Tests.Classes.Channels
Assert.AreSame(_onSuccessException, _channel.OnErrorOccurredInvocations[0]);
}
}
}
}
@@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Messages.Connection;
@@ -70,4 +71,4 @@ namespace Renci.SshNet.Tests.Classes.Channels
Assert.AreSame(_onWindowAdjustException, _channel.OnErrorOccurredInvocations[0]);
}
}
}
}
@@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
namespace Renci.SshNet.Tests.Classes.Channels
@@ -59,4 +60,4 @@ namespace Renci.SshNet.Tests.Classes.Channels
Assert.AreSame(_onDisconnectedException, _channel.OnErrorOccurredInvocations[0]);
}
}
}
}
@@ -1,7 +1,8 @@
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
namespace Renci.SshNet.Tests.Classes.Channels
@@ -35,7 +36,8 @@ namespace Renci.SshNet.Tests.Classes.Channels
protected override void SetupMocks()
{
SessionMock.Setup(p => p.IsConnected).Returns(true);
_ = SessionMock.Setup(p => p.IsConnected)
.Returns(true);
}
protected override void Arrange()
@@ -72,4 +74,4 @@ namespace Renci.SshNet.Tests.Classes.Channels
Assert.AreEqual(0, _channelExceptionRegister.Count);
}
}
}
}
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Renci.SshNet.Channels;
using Renci.SshNet.Messages.Connection;
@@ -58,7 +59,7 @@ namespace Renci.SshNet.Tests.Classes.Channels
public void InitializeRemoteChannelInfo(uint remoteChannelNumber, uint remoteWindowSize, uint remotePacketSize)
{
base.InitializeRemoteInfo(remoteChannelNumber, remoteWindowSize, remotePacketSize);
InitializeRemoteInfo(remoteChannelNumber, remoteWindowSize, remotePacketSize);
}
protected override void OnClose()
@@ -66,7 +67,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
base.OnClose();
if (OnCloseException != null)
{
throw OnCloseException;
}
}
protected override void OnData(byte[] data)
@@ -74,7 +77,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
base.OnData(data);
if (OnDataException != null)
{
throw OnDataException;
}
}
protected override void OnDisconnected()
@@ -82,7 +87,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
base.OnDisconnected();
if (OnDisconnectedException != null)
{
throw OnDisconnectedException;
}
}
protected override void OnEof()
@@ -90,7 +97,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
base.OnEof();
if (OnEofException != null)
{
throw OnEofException;
}
}
protected override void OnExtendedData(byte[] data, uint dataTypeCode)
@@ -98,7 +107,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
base.OnExtendedData(data, dataTypeCode);
if (OnExtendedDataException != null)
{
throw OnExtendedDataException;
}
}
protected override void OnErrorOccured(Exception exp)
@@ -106,7 +117,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
OnErrorOccurredInvocations.Add(exp);
if (OnErrorOccurredException != null)
{
throw OnErrorOccurredException;
}
}
protected override void OnFailure()
@@ -114,7 +127,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
base.OnFailure();
if (OnFailureException != null)
{
throw OnFailureException;
}
}
protected override void OnRequest(RequestInfo info)
@@ -122,7 +137,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
base.OnRequest(info);
if (OnRequestException != null)
{
throw OnRequestException;
}
}
protected override void OnSuccess()
@@ -130,7 +147,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
base.OnSuccess();
if (OnSuccessException != null)
{
throw OnSuccessException;
}
}
protected override void OnWindowAdjust(uint bytesToAdd)
@@ -138,7 +157,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
base.OnWindowAdjust(bytesToAdd);
if (OnWindowAdjustException != null)
{
throw OnWindowAdjustException;
}
}
protected override void OnOpenConfirmation(uint remoteChannelNumber, uint initialWindowSize, uint maximumPacketSize)
@@ -146,7 +167,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
base.OnOpenConfirmation(remoteChannelNumber, initialWindowSize, maximumPacketSize);
if (OnOpenConfirmationException != null)
{
throw OnOpenConfirmationException;
}
}
protected override void OnOpenFailure(uint reasonCode, string description, string language)
@@ -154,7 +177,9 @@ namespace Renci.SshNet.Tests.Classes.Channels
base.OnOpenFailure(reasonCode, description, language);
if (OnOpenFailureException != null)
{
throw OnOpenFailureException;
}
}
}
}
@@ -1,7 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Renci.SshNet.Common;
using Renci.SshNet.Security.Cryptography;
using Renci.SshNet.Tests.Common;
using System;
namespace Renci.SshNet.Tests.Classes
@@ -19,10 +20,10 @@ namespace Renci.SshNet.Tests.Classes
[Ignore] // placeholder
public void CipherInfoConstructorTest()
{
int keySize = 0; // TODO: Initialize to an appropriate value
var keySize = 0; // TODO: Initialize to an appropriate value
Func<byte[], byte[], Cipher> cipher = null; // TODO: Initialize to an appropriate value
CipherInfo target = new CipherInfo(keySize, cipher);
var target = new CipherInfo(keySize, cipher);
Assert.Inconclusive("TODO: Implement code to verify target");
}
}
}
}
@@ -1,7 +1,8 @@
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
namespace Renci.SshNet.Tests.Classes
{
@@ -1,5 +1,7 @@
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
namespace Renci.SshNet.Tests.Classes
@@ -19,52 +21,68 @@ namespace Renci.SshNet.Tests.Classes
{
var seq = new MockSequence();
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
SessionMock.InSequence(seq).Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_BANNER"));
ConnectionInfoMock.InSequence(seq).Setup(p => p.CreateNoneAuthenticationMethod())
.Returns(NoneAuthenticationMethodMock.Object);
NoneAuthenticationMethodMock.InSequence(seq)
.Setup(p => p.Authenticate(SessionMock.Object))
.Returns(AuthenticationResult.Failure);
ConnectionInfoMock.InSequence(seq)
.Setup(p => p.AuthenticationMethods)
.Returns(new List<IAuthenticationMethod>
{
KeyboardInteractiveAuthenticationMethodMock.Object,
PasswordAuthenticationMethodMock.Object,
PublicKeyAuthenticationMethodMock.Object
});
NoneAuthenticationMethodMock.InSequence(seq).Setup(p => p.AllowedAuthentications).Returns(new[] { "password" });
KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("keyboard-interactive");
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
PasswordAuthenticationMethodMock.InSequence(seq)
_ = SessionMock.InSequence(seq)
.Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
_ = SessionMock.InSequence(seq)
.Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
_ = SessionMock.InSequence(seq)
.Setup(p => p.RegisterMessage("SSH_MSG_USERAUTH_BANNER"));
_ = ConnectionInfoMock.InSequence(seq)
.Setup(p => p.CreateNoneAuthenticationMethod())
.Returns(NoneAuthenticationMethodMock.Object);
_ = NoneAuthenticationMethodMock.InSequence(seq)
.Setup(p => p.Authenticate(SessionMock.Object))
.Returns(AuthenticationResult.PartialSuccess);
PasswordAuthenticationMethodMock.InSequence(seq)
.Returns(AuthenticationResult.Failure);
_ = ConnectionInfoMock.InSequence(seq)
.Setup(p => p.AuthenticationMethods)
.Returns(new List<IAuthenticationMethod>
{
KeyboardInteractiveAuthenticationMethodMock.Object,
PasswordAuthenticationMethodMock.Object,
PublicKeyAuthenticationMethodMock.Object
});
_ = NoneAuthenticationMethodMock.InSequence(seq)
.Setup(p => p.AllowedAuthentications)
.Returns(new[] {"password", "publickey"});
KeyboardInteractiveAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("keyboard-interactive");
PasswordAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("password");
PublicKeyAuthenticationMethodMock.InSequence(seq).Setup(p => p.Name).Returns("publickey");
PublicKeyAuthenticationMethodMock.InSequence(seq)
.Setup(p => p.Authenticate(SessionMock.Object))
.Returns(AuthenticationResult.Failure);
PublicKeyAuthenticationMethodMock.InSequence(seq)
.Setup(p => p.Name)
.Returns("publickey");
PasswordAuthenticationMethodMock.InSequence(seq)
.Setup(p => p.Authenticate(SessionMock.Object))
.Returns(AuthenticationResult.Success);
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
SessionMock.InSequence(seq).Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_BANNER"));
.Returns(new[] { "password" });
_ = KeyboardInteractiveAuthenticationMethodMock.InSequence(seq)
.Setup(p => p.Name)
.Returns("keyboard-interactive");
_ = PasswordAuthenticationMethodMock.InSequence(seq)
.Setup(p => p.Name)
.Returns("password");
_ = PublicKeyAuthenticationMethodMock.InSequence(seq)
.Setup(p => p.Name)
.Returns("publickey");
_ = PasswordAuthenticationMethodMock.InSequence(seq)
.Setup(p => p.Authenticate(SessionMock.Object))
.Returns(AuthenticationResult.PartialSuccess);
_ = PasswordAuthenticationMethodMock.InSequence(seq)
.Setup(p => p.AllowedAuthentications)
.Returns(new[] {"password", "publickey"});
_ = KeyboardInteractiveAuthenticationMethodMock.InSequence(seq)
.Setup(p => p.Name)
.Returns("keyboard-interactive");
_ = PasswordAuthenticationMethodMock.InSequence(seq)
.Setup(p => p.Name)
.Returns("password");
_ = PublicKeyAuthenticationMethodMock.InSequence(seq)
.Setup(p => p.Name)
.Returns("publickey");
_ = PublicKeyAuthenticationMethodMock.InSequence(seq)
.Setup(p => p.Authenticate(SessionMock.Object))
.Returns(AuthenticationResult.Failure);
_ = PublicKeyAuthenticationMethodMock.InSequence(seq)
.Setup(p => p.Name)
.Returns("publickey");
_ = PasswordAuthenticationMethodMock.InSequence(seq)
.Setup(p => p.Authenticate(SessionMock.Object))
.Returns(AuthenticationResult.Success);
_ = SessionMock.InSequence(seq)
.Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_FAILURE"));
_ = SessionMock.InSequence(seq)
.Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_SUCCESS"));
_ = SessionMock.InSequence(seq)
.Setup(p => p.UnRegisterMessage("SSH_MSG_USERAUTH_BANNER"));
}
protected override void Arrange()
@@ -11,7 +11,7 @@ namespace Renci.SshNet.Tests.Classes
public void BytesSentTest()
{
var target = new CommandAsyncResult();
int expected = new Random().Next();
var expected = new Random().Next();
target.BytesSent = expected;
@@ -1,6 +1,7 @@
using System;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Renci.SshNet.Common;
using Renci.SshNet.Tests.Common;
@@ -19,10 +20,9 @@ namespace Renci.SshNet.Tests.Classes.Common
///</summary>
public void EndInvokeTest1Helper<TResult>()
{
AsyncResult<TResult> target = CreateAsyncResult<TResult>(); // TODO: Initialize to an appropriate value
TResult expected = default(TResult); // TODO: Initialize to an appropriate value
TResult actual;
actual = target.EndInvoke();
var target = CreateAsyncResult<TResult>(); // TODO: Initialize to an appropriate value
var expected = default(TResult); // TODO: Initialize to an appropriate value
var actual = target.EndInvoke();
Assert.AreEqual(expected, actual);
Assert.Inconclusive("Verify the correctness of this test method.");
}
@@ -45,9 +45,9 @@ namespace Renci.SshNet.Tests.Classes.Common
///</summary>
public void SetAsCompletedTest1Helper<TResult>()
{
AsyncResult<TResult> target = CreateAsyncResult<TResult>(); // TODO: Initialize to an appropriate value
TResult result = default(TResult); // TODO: Initialize to an appropriate value
bool completedSynchronously = false; // TODO: Initialize to an appropriate value
var target = CreateAsyncResult<TResult>(); // TODO: Initialize to an appropriate value
TResult result = default; // TODO: Initialize to an appropriate value
var completedSynchronously = false; // TODO: Initialize to an appropriate value
target.SetAsCompleted(result, completedSynchronously);
Assert.Inconclusive("A method that does not return a value cannot be verified.");
}
@@ -71,7 +71,7 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void EndInvokeTest()
{
AsyncResult target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
var target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
target.EndInvoke();
Assert.Inconclusive("A method that does not return a value cannot be verified.");
}
@@ -82,9 +82,9 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void SetAsCompletedTest()
{
AsyncResult target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
var target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
Exception exception = null; // TODO: Initialize to an appropriate value
bool completedSynchronously = false; // TODO: Initialize to an appropriate value
var completedSynchronously = false; // TODO: Initialize to an appropriate value
target.SetAsCompleted(exception, completedSynchronously);
Assert.Inconclusive("A method that does not return a value cannot be verified.");
}
@@ -95,9 +95,8 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void AsyncStateTest()
{
AsyncResult target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
object actual;
actual = target.AsyncState;
var target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
var actual = target.AsyncState;
Assert.Inconclusive("Verify the correctness of this test method.");
}
@@ -107,9 +106,8 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void AsyncWaitHandleTest()
{
AsyncResult target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
WaitHandle actual;
actual = target.AsyncWaitHandle;
var target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
var actual = target.AsyncWaitHandle;
Assert.Inconclusive("Verify the correctness of this test method.");
}
@@ -119,9 +117,8 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void CompletedSynchronouslyTest()
{
AsyncResult target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
bool actual;
actual = target.CompletedSynchronously;
var target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
var actual = target.CompletedSynchronously;
Assert.Inconclusive("Verify the correctness of this test method.");
}
@@ -131,9 +128,8 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void IsCompletedTest()
{
AsyncResult target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
bool actual;
actual = target.IsCompleted;
var target = CreateAsyncResult(); // TODO: Initialize to an appropriate value
var actual = target.IsCompleted;
Assert.Inconclusive("Verify the correctness of this test method.");
}
}
@@ -19,8 +19,8 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void AuthenticationPasswordChangeEventArgsConstructorTest()
{
string username = string.Empty; // TODO: Initialize to an appropriate value
AuthenticationPasswordChangeEventArgs target = new AuthenticationPasswordChangeEventArgs(username);
var username = string.Empty; // TODO: Initialize to an appropriate value
var target = new AuthenticationPasswordChangeEventArgs(username);
Assert.Inconclusive("TODO: Implement code to verify target");
}
@@ -31,7 +31,7 @@ namespace Renci.SshNet.Tests.Classes.Common
public void NewPasswordTest()
{
string username = string.Empty; // TODO: Initialize to an appropriate value
AuthenticationPasswordChangeEventArgs target = new AuthenticationPasswordChangeEventArgs(username); // TODO: Initialize to an appropriate value
var target = new AuthenticationPasswordChangeEventArgs(username); // TODO: Initialize to an appropriate value
byte[] expected = null; // TODO: Initialize to an appropriate value
byte[] actual;
target.NewPassword = expected;
@@ -20,11 +20,11 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void AuthenticationPromptEventArgsConstructorTest()
{
string username = string.Empty; // TODO: Initialize to an appropriate value
string instruction = string.Empty; // TODO: Initialize to an appropriate value
string language = string.Empty; // TODO: Initialize to an appropriate value
var username = string.Empty; // TODO: Initialize to an appropriate value
var instruction = string.Empty; // TODO: Initialize to an appropriate value
var language = string.Empty; // TODO: Initialize to an appropriate value
IEnumerable<AuthenticationPrompt> prompts = null; // TODO: Initialize to an appropriate value
AuthenticationPromptEventArgs target = new AuthenticationPromptEventArgs(username, instruction, language, prompts);
var target = new AuthenticationPromptEventArgs(username, instruction, language, prompts);
Assert.Inconclusive("TODO: Implement code to verify target");
}
}
@@ -17,10 +17,10 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void AuthenticationPromptConstructorTest()
{
int id = 0; // TODO: Initialize to an appropriate value
bool isEchoed = false; // TODO: Initialize to an appropriate value
string request = string.Empty; // TODO: Initialize to an appropriate value
AuthenticationPrompt target = new AuthenticationPrompt(id, isEchoed, request);
var id = 0; // TODO: Initialize to an appropriate value
var isEchoed = false; // TODO: Initialize to an appropriate value
var request = string.Empty; // TODO: Initialize to an appropriate value
var target = new AuthenticationPrompt(id, isEchoed, request);
Assert.Inconclusive("TODO: Implement code to verify target");
}
@@ -30,14 +30,13 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void ResponseTest()
{
int id = 0; // TODO: Initialize to an appropriate value
bool isEchoed = false; // TODO: Initialize to an appropriate value
string request = string.Empty; // TODO: Initialize to an appropriate value
AuthenticationPrompt target = new AuthenticationPrompt(id, isEchoed, request); // TODO: Initialize to an appropriate value
string expected = string.Empty; // TODO: Initialize to an appropriate value
string actual;
var id = 0; // TODO: Initialize to an appropriate value
var isEchoed = false; // TODO: Initialize to an appropriate value
var request = string.Empty; // TODO: Initialize to an appropriate value
var target = new AuthenticationPrompt(id, isEchoed, request); // TODO: Initialize to an appropriate value
var expected = string.Empty; // TODO: Initialize to an appropriate value
target.Response = expected;
actual = target.Response;
var actual = target.Response;
Assert.AreEqual(expected, actual);
Assert.Inconclusive("Verify the correctness of this test method.");
}
@@ -28,7 +28,7 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestClass]
public class BigIntegerTest
{
private static readonly byte[] huge_a =
private static readonly byte[] Huge_a =
{
0x1D, 0x33, 0xFB, 0xFE, 0xB1, 0x2, 0x85, 0x44, 0xCA, 0xDC, 0xFB, 0x70, 0xD, 0x39,
0xB1, 0x47, 0xB6, 0xE6, 0xA2, 0xD1, 0x19, 0x1E, 0x9F, 0xE4, 0x3C, 0x1E, 0x16, 0x56, 0x13, 0x9C, 0x4D, 0xD3,
@@ -36,7 +36,7 @@ namespace Renci.SshNet.Tests.Classes.Common
0xF6, 0x8C
};
private static readonly byte[] huge_b =
private static readonly byte[] Huge_b =
{
0x96, 0x5, 0xDA, 0xFE, 0x93, 0x17, 0xC1, 0x93, 0xEC, 0x2F, 0x30, 0x2D, 0x8F,
0x28, 0x13, 0x99, 0x70, 0xF4, 0x4C, 0x60, 0xA6, 0x49, 0x24, 0xF9, 0xB3, 0x4A, 0x41, 0x67, 0xDC, 0xDD, 0xB1,
@@ -44,7 +44,7 @@ namespace Renci.SshNet.Tests.Classes.Common
0xA8, 0xC8, 0xB0, 0x20, 0x95, 0xE6, 0x4C, 0xE1, 0xE0, 0x4B, 0x49, 0xD5, 0x5A, 0xB7
};
private static readonly byte[] huge_add =
private static readonly byte[] Huge_add =
{
0xB3, 0x38, 0xD5, 0xFD, 0x45, 0x1A, 0x46, 0xD8, 0xB6, 0xC, 0x2C, 0x9E, 0x9C,
0x61, 0xC4, 0xE0, 0x26, 0xDB, 0xEF, 0x31, 0xC0, 0x67, 0xC3, 0xDD, 0xF0, 0x68, 0x57, 0xBD, 0xEF, 0x79, 0xFF,
@@ -52,7 +52,7 @@ namespace Renci.SshNet.Tests.Classes.Common
0x16, 0xBF, 0x3D, 0x20, 0x95, 0xE6, 0x4C, 0xE1, 0xE0, 0x4B, 0x49, 0xD5, 0x5A, 0xB7
};
private static readonly byte[] a_m_b =
private static readonly byte[] A_m_b =
{
0x87, 0x2D, 0x21, 0x0, 0x1E, 0xEB, 0xC3, 0xB0, 0xDD, 0xAC, 0xCB, 0x43, 0x7E, 0x10,
0x9E, 0xAE, 0x45, 0xF2, 0x55, 0x71, 0x73, 0xD4, 0x7A, 0xEB, 0x88, 0xD3, 0xD4, 0xEE, 0x36, 0xBE, 0x9B, 0x2D,
@@ -60,7 +60,7 @@ namespace Renci.SshNet.Tests.Classes.Common
0x2D, 0xDC, 0xDE, 0x6A, 0x19, 0xB3, 0x1E, 0x1F, 0xB4, 0xB6, 0x2A, 0xA5, 0x48
};
private static readonly byte[] b_m_a =
private static readonly byte[] B_m_a =
{
0x79, 0xD2, 0xDE, 0xFF, 0xE1, 0x14, 0x3C, 0x4F, 0x22, 0x53, 0x34, 0xBC, 0x81,
0xEF, 0x61, 0x51, 0xBA, 0xD, 0xAA, 0x8E, 0x8C, 0x2B, 0x85, 0x14, 0x77, 0x2C, 0x2B, 0x11, 0xC9, 0x41, 0x64,
@@ -68,7 +68,7 @@ namespace Renci.SshNet.Tests.Classes.Common
0x3B, 0xD2, 0x23, 0x21, 0x95, 0xE6, 0x4C, 0xE1, 0xE0, 0x4B, 0x49, 0xD5, 0x5A, 0xB7
};
private static readonly byte[] huge_mul =
private static readonly byte[] Huge_mul =
{
0xFE, 0x83, 0xE1, 0x9B, 0x8D, 0x61, 0x40, 0xD1, 0x60, 0x19, 0xBD, 0x38, 0xF0,
0xFF, 0x90, 0xAE, 0xDD, 0xAE, 0x73, 0x2C, 0x20, 0x23, 0xCF, 0x6, 0x7A, 0xB4, 0x1C, 0xE7, 0xD9, 0x64, 0x96,
@@ -79,18 +79,18 @@ namespace Renci.SshNet.Tests.Classes.Common
0x57, 0x40, 0x51, 0xB6, 0x5D, 0xC, 0x17, 0xD1, 0x86, 0xE9, 0xA4, 0x20
};
private static readonly byte[] huge_div = {0x0};
private static readonly byte[] Huge_div = {0x0};
private static readonly byte[] huge_rem =
private static readonly byte[] Huge_rem =
{
0x1D, 0x33, 0xFB, 0xFE, 0xB1, 0x2, 0x85, 0x44, 0xCA, 0xDC, 0xFB, 0x70, 0xD,
0x39, 0xB1, 0x47, 0xB6, 0xE6, 0xA2, 0xD1, 0x19, 0x1E, 0x9F, 0xE4, 0x3C, 0x1E, 0x16, 0x56, 0x13, 0x9C, 0x4D,
0xD3, 0x5C, 0x74, 0xC9, 0xBD, 0xFA, 0x56, 0x40, 0x58, 0xAC, 0x20, 0x6B, 0x55, 0xA2, 0xD5, 0x41, 0x38, 0xA4,
0x6D, 0xF6, 0x8C
};
private static readonly byte[][] add_a = {new byte[] {1}, new byte[] {0xFF}, huge_a};
private static readonly byte[][] add_b = {new byte[] {1}, new byte[] {1}, huge_b};
private static readonly byte[][] add_c = {new byte[] {2}, new byte[] {0}, huge_add};
private static readonly byte[][] Add_a = { new byte[] { 1 }, new byte[] { 0xFF }, Huge_a };
private static readonly byte[][] Add_b = { new byte[] { 1 }, new byte[] { 1 }, Huge_b };
private static readonly byte[][] Add_c = { new byte[] { 2 }, new byte[] { 0 }, Huge_add };
private readonly NumberFormatInfo _nfi = NumberFormatInfo.InvariantInfo;
private NumberFormatInfo _nfiUser;
@@ -98,22 +98,24 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestInitialize]
public void SetUpFixture()
{
_nfiUser = new NumberFormatInfo();
_nfiUser.CurrencyDecimalDigits = 3;
_nfiUser.CurrencyDecimalSeparator = ":";
_nfiUser.CurrencyGroupSeparator = "/";
_nfiUser.CurrencyGroupSizes = new[] { 2, 1, 0 };
_nfiUser.CurrencyNegativePattern = 10; // n $-
_nfiUser.CurrencyPositivePattern = 3; // n $
_nfiUser.CurrencySymbol = "XYZ";
_nfiUser.PercentDecimalDigits = 1;
_nfiUser.PercentDecimalSeparator = ";";
_nfiUser.PercentGroupSeparator = "~";
_nfiUser.PercentGroupSizes = new[] { 1 };
_nfiUser.PercentNegativePattern = 2;
_nfiUser.PercentPositivePattern = 2;
_nfiUser.PercentSymbol = "%%%";
_nfiUser.NumberDecimalSeparator = ".";
_nfiUser = new NumberFormatInfo
{
CurrencyDecimalDigits = 3,
CurrencyDecimalSeparator = ":",
CurrencyGroupSeparator = "/",
CurrencyGroupSizes = new[] { 2, 1, 0 },
CurrencyNegativePattern = 10, // n $-
CurrencyPositivePattern = 3, // n $
CurrencySymbol = "XYZ",
PercentDecimalDigits = 1,
PercentDecimalSeparator = ";",
PercentGroupSeparator = "~",
PercentGroupSizes = new[] { 1 },
PercentNegativePattern = 2,
PercentPositivePattern = 2,
PercentSymbol = "%%%",
NumberDecimalSeparator = "."
};
}
[TestMethod]
@@ -136,10 +138,10 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void TestHugeMul()
{
var a = new BigInteger(huge_a);
var b = new BigInteger(huge_b);
var a = new BigInteger(Huge_a);
var b = new BigInteger(Huge_b);
Assert.IsTrue(huge_mul.IsEqualTo((a * b).ToByteArray()));
Assert.IsTrue(Huge_mul.IsEqualTo((a * b).ToByteArray()));
}
[TestMethod]
@@ -152,11 +154,13 @@ namespace Renci.SshNet.Tests.Classes.Common
for (var j = 0; j < values.Length; ++j)
{
if (values[j] == 0)
{
continue;
}
var a = new BigInteger(values[i]);
var b = new BigInteger(values[j]);
BigInteger d;
var c = BigInteger.DivRem(a, b, out d);
var c = BigInteger.DivRem(a, b, out var d);
Assert.AreEqual(values[i] / values[j], (long)c, "#a_" + i + "_" + j);
Assert.AreEqual(values[i] % values[j], (long)d, "#b_" + i + "_" + j);
@@ -167,13 +171,12 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void TestHugeDivRem()
{
var a = new BigInteger(huge_a);
var b = new BigInteger(huge_b);
BigInteger d;
var c = BigInteger.DivRem(a, b, out d);
var a = new BigInteger(Huge_a);
var b = new BigInteger(Huge_b);
var c = BigInteger.DivRem(a, b, out var d);
AssertEqual(huge_div, c.ToByteArray());
AssertEqual(huge_rem, d.ToByteArray());
AssertEqual(Huge_div, c.ToByteArray());
AssertEqual(Huge_rem, d.ToByteArray());
}
[TestMethod]
@@ -181,7 +184,7 @@ namespace Renci.SshNet.Tests.Classes.Common
{
try
{
BigInteger.Pow(1, -1);
_ = BigInteger.Pow(1, -1);
Assert.Fail("#1");
}
catch (ArgumentOutOfRangeException) { }
@@ -198,14 +201,14 @@ namespace Renci.SshNet.Tests.Classes.Common
{
try
{
BigInteger.ModPow(1, -1, 5);
_ = BigInteger.ModPow(1, -1, 5);
Assert.Fail("#1");
}
catch (ArgumentOutOfRangeException) { }
try
{
BigInteger.ModPow(1, 5, 0);
_ = BigInteger.ModPow(1, 5, 0);
Assert.Fail("#2");
}
catch (DivideByZeroException) { }
@@ -281,8 +284,7 @@ namespace Renci.SshNet.Tests.Classes.Common
{
try
{
BigInteger d;
BigInteger.DivRem(100, 0, out d);
_ = BigInteger.DivRem(100, 0, out var d);
Assert.Fail("#1");
}
catch (DivideByZeroException)
@@ -293,16 +295,16 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void TestAdd()
{
for (var i = 0; i < add_a.Length; ++i)
for (var i = 0; i < Add_a.Length; ++i)
{
var a = new BigInteger(add_a[i]);
var b = new BigInteger(add_b[i]);
var c = new BigInteger(add_c[i]);
var a = new BigInteger(Add_a[i]);
var b = new BigInteger(Add_b[i]);
var c = new BigInteger(Add_c[i]);
Assert.AreEqual(c, a + b, "#" + i + "a");
Assert.AreEqual(c, b + a, "#" + i + "b");
Assert.AreEqual(c, BigInteger.Add(a, b), "#" + i + "c");
AssertEqual(add_c[i], (a + b).ToByteArray());
AssertEqual(Add_c[i], (a + b).ToByteArray());
}
}
@@ -326,11 +328,11 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void TestHugeSub()
{
var a = new BigInteger(huge_a);
var b = new BigInteger(huge_b);
var a = new BigInteger(Huge_a);
var b = new BigInteger(Huge_b);
AssertEqual(a_m_b, (a - b).ToByteArray());
AssertEqual(b_m_a, (b - a).ToByteArray());
AssertEqual(A_m_b, (a - b).ToByteArray());
AssertEqual(B_m_a, (b - a).ToByteArray());
}
[TestMethod]
@@ -732,7 +734,7 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void TestIntCtorProperties()
{
BigInteger a = new BigInteger(10);
var a = new BigInteger(10);
Assert.IsTrue(a.IsEven, "#1");
Assert.IsFalse(a.IsOne, "#2");
Assert.IsFalse(a.IsPowerOfTwo, "#3");
@@ -784,11 +786,11 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void TestToStringFmtProvider()
{
NumberFormatInfo info = new NumberFormatInfo
{
NegativeSign = ">",
PositiveSign = "%"
};
var info = new NumberFormatInfo
{
NegativeSign = ">",
PositiveSign = "%"
};
Assert.AreEqual("10", new BigInteger(10).ToString(info), "#1");
Assert.AreEqual(">10", new BigInteger(-10).ToString(info), "#2");
@@ -801,12 +803,16 @@ namespace Renci.SshNet.Tests.Classes.Common
Assert.AreEqual("10", new BigInteger(10).ToString("R", info), "#9");
Assert.AreEqual(">10", new BigInteger(-10).ToString("R", info), "#10");
info = new NumberFormatInfo();
info.NegativeSign = "#$%";
info = new NumberFormatInfo
{
NegativeSign = "#$%"
};
Assert.AreEqual("#$%10", new BigInteger(-10).ToString(info), "#2");
Assert.AreEqual("#$%10", new BigInteger(-10).ToString(null, info), "#2");
info = new NumberFormatInfo();
Assert.AreEqual("-10", new BigInteger(-10).ToString(info), "#2");
}
@@ -816,21 +822,21 @@ namespace Renci.SshNet.Tests.Classes.Common
{
try
{
int v = (int)new BigInteger(huge_a);
_ = (int) new BigInteger(Huge_a);
Assert.Fail("#1");
}
catch (OverflowException) { }
try
{
int v = (int)new BigInteger(1L + int.MaxValue);
_ = (int) new BigInteger(1L + int.MaxValue);
Assert.Fail("#2");
}
catch (OverflowException) { }
try
{
int v = (int)new BigInteger(-1L + int.MinValue);
_ = (int) new BigInteger(-1L + int.MinValue);
Assert.Fail("#3");
}
catch (OverflowException) { }
@@ -845,7 +851,7 @@ namespace Renci.SshNet.Tests.Classes.Common
{
try
{
long v = (long)new BigInteger(huge_a);
_ = (long) new BigInteger(Huge_a);
Assert.Fail("#1");
}
catch (OverflowException) { }
@@ -853,7 +859,7 @@ namespace Renci.SshNet.Tests.Classes.Common
//long.MaxValue + 1
try
{
long v = (long)new BigInteger(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00 });
_ = (long) new BigInteger(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00 });
Assert.Fail("#2");
}
catch (OverflowException) { }
@@ -861,7 +867,7 @@ namespace Renci.SshNet.Tests.Classes.Common
//TODO long.MinValue - 1
try
{
long v = (long)new BigInteger(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF });
_ = (long) new BigInteger(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF });
Assert.Fail("#3");
}
catch (OverflowException) { }
@@ -931,14 +937,14 @@ namespace Renci.SshNet.Tests.Classes.Common
try
{
short x = (short)new BigInteger(10000000);
_ = (short) new BigInteger(10000000);
Assert.Fail("#3");
}
catch (OverflowException) { }
try
{
short x = (short)new BigInteger(-10000000);
_ = (short) new BigInteger(-10000000);
Assert.Fail("#4");
}
catch (OverflowException) { }
@@ -949,7 +955,7 @@ namespace Renci.SshNet.Tests.Classes.Common
{
try
{
new BigInteger(double.NaN);
_ = new BigInteger(double.NaN);
Assert.Fail();
}
catch (OverflowException)
@@ -962,7 +968,7 @@ namespace Renci.SshNet.Tests.Classes.Common
{
try
{
new BigInteger(double.NegativeInfinity);
_ = new BigInteger(double.NegativeInfinity);
Assert.Fail();
}
catch (OverflowException)
@@ -975,7 +981,7 @@ namespace Renci.SshNet.Tests.Classes.Common
{
try
{
new BigInteger(double.PositiveInfinity);
_ = new BigInteger(double.PositiveInfinity);
Assert.Fail();
}
catch (OverflowException)
@@ -1019,9 +1025,9 @@ namespace Renci.SshNet.Tests.Classes.Common
Assert.AreEqual(result4, (double)new BigInteger(new byte[] { 0, 0, 0, 0, 48, 128, 208, 159, 60, 46, 59, 3 }), "#13");
Assert.AreEqual(result5, (double)new BigInteger(new byte[] { 0, 0, 0, 0, 64, 128, 208, 159, 60, 46, 59, 3 }), "#14");
Assert.AreEqual(BitConverter.Int64BitsToDouble(-2748107935317889142), (double)new BigInteger(huge_a), "#15");
Assert.AreEqual(BitConverter.Int64BitsToDouble(-2354774254443231289), (double)new BigInteger(huge_b), "#16");
Assert.AreEqual(BitConverter.Int64BitsToDouble(8737073938546854790), (double)new BigInteger(huge_mul), "#17");
Assert.AreEqual(BitConverter.Int64BitsToDouble(-2748107935317889142), (double)new BigInteger(Huge_a), "#15");
Assert.AreEqual(BitConverter.Int64BitsToDouble(-2354774254443231289), (double)new BigInteger(Huge_b), "#16");
Assert.AreEqual(BitConverter.Int64BitsToDouble(8737073938546854790), (double)new BigInteger(Huge_mul), "#17");
Assert.AreEqual(BitConverter.Int64BitsToDouble(6912920136897069886), (double)(2278888483353476799 * BigInteger.Pow(2, 451)), "#18");
Assert.AreEqual(double.PositiveInfinity, (double)(843942696292817306 * BigInteger.Pow(2, 965)), "#19");
@@ -1070,14 +1076,14 @@ namespace Renci.SshNet.Tests.Classes.Common
{
try
{
BigInteger.Parse(null);
_ = BigInteger.Parse(null);
Assert.Fail("#1");
}
catch (ArgumentNullException) { }
try
{
BigInteger.Parse("");
_ = BigInteger.Parse("");
Assert.Fail("#2");
}
catch (FormatException) { }
@@ -1085,28 +1091,28 @@ namespace Renci.SshNet.Tests.Classes.Common
try
{
BigInteger.Parse(" ");
_ = BigInteger.Parse(" ");
Assert.Fail("#3");
}
catch (FormatException) { }
try
{
BigInteger.Parse("hh");
_ = BigInteger.Parse("hh");
Assert.Fail("#4");
}
catch (FormatException) { }
try
{
BigInteger.Parse("-");
_ = BigInteger.Parse("-");
Assert.Fail("#5");
}
catch (FormatException) { }
try
{
BigInteger.Parse("-+");
_ = BigInteger.Parse("-+");
Assert.Fail("#6");
}
catch (FormatException) { }
@@ -1137,7 +1143,7 @@ namespace Renci.SshNet.Tests.Classes.Common
try
{
BigInteger.Parse("2E3.0", NumberStyles.AllowExponent); // decimal notation for the exponent
_ = BigInteger.Parse("2E3.0", NumberStyles.AllowExponent); // decimal notation for the exponent
Assert.Fail("#25");
}
catch (FormatException)
@@ -1146,7 +1152,7 @@ namespace Renci.SshNet.Tests.Classes.Common
try
{
Int32.Parse("2" + dsep + "09E1", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent);
_ = int.Parse("2" + dsep + "09E1", NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent);
Assert.Fail("#26");
}
catch (OverflowException)
@@ -1157,9 +1163,7 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void TryParse_Value_ShouldReturnFalseWhenValueIsNull()
{
BigInteger x;
var actual = BigInteger.TryParse(null, out x);
var actual = BigInteger.TryParse(null, out var x);
Assert.IsFalse(actual);
Assert.AreEqual(BigInteger.Zero, x);
@@ -1168,9 +1172,7 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void TryParse_Value()
{
BigInteger x;
Assert.IsFalse(BigInteger.TryParse("", out x));
Assert.IsFalse(BigInteger.TryParse("", out var x));
Assert.AreEqual(BigInteger.Zero, x);
Assert.IsFalse(BigInteger.TryParse(" ", out x));
@@ -1198,9 +1200,7 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void TryParse_ValueAndStyleAndProvider()
{
BigInteger x;
Assert.IsFalse(BigInteger.TryParse("null", NumberStyles.None, null, out x));
Assert.IsFalse(BigInteger.TryParse("null", NumberStyles.None, null, out var x));
Assert.AreEqual(BigInteger.Zero, x);
Assert.IsFalse(BigInteger.TryParse("-10", NumberStyles.None, null, out x));
@@ -1252,9 +1252,7 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void TryParse_ValueAndStyleAndProvider_ShouldReturnFalseWhenValueIsNull()
{
BigInteger x;
var actual = BigInteger.TryParse(null, NumberStyles.Any, CultureInfo.InvariantCulture, out x);
var actual = BigInteger.TryParse(null, NumberStyles.Any, CultureInfo.InvariantCulture, out var x);
Assert.IsFalse(actual);
Assert.AreEqual(BigInteger.Zero, x);
@@ -1284,20 +1282,17 @@ namespace Renci.SshNet.Tests.Classes.Common
{
var old = Thread.CurrentThread.CurrentCulture;
var cur = (CultureInfo)old.Clone();
var ninfo = new NumberFormatInfo
{
NegativeSign = ">",
PositiveSign = "%"
};
cur.NumberFormat = ninfo;
cur.NumberFormat = new NumberFormatInfo
{
NegativeSign = ">",
PositiveSign = "%"
};
Thread.CurrentThread.CurrentCulture = cur;
try
{
BigInteger x;
Assert.IsTrue(BigInteger.TryParse("%11", out x));
Assert.IsTrue(BigInteger.TryParse("%11", out var x));
Assert.AreEqual(11, (int) x);
Assert.IsTrue(BigInteger.TryParse(">11", out x));
@@ -1403,7 +1398,7 @@ namespace Renci.SshNet.Tests.Classes.Common
public void RightShiftByInt()
{
var v = BigInteger.Parse("230794411440927908251127453634");
v = v * BigInteger.Pow(2, 70);
v *= BigInteger.Pow(2, 70);
Assert.AreEqual("272473948255566133040220955950698177909118065442816", (v >> 0).ToString(), "#0");
Assert.AreEqual("136236974127783066520110477975349088954559032721408", (v >> 1).ToString(), "#1");
@@ -1482,12 +1477,15 @@ namespace Renci.SshNet.Tests.Classes.Common
{
BigInteger b = 0;
for (var i = 1; i <= 16; i++)
b = b * 256 + i;
{
b = (b * 256) + i;
}
var p = BigInteger.Pow(2, 32);
Assert.AreEqual("1339673755198158349044581307228491536", b.ToString());
Assert.AreEqual("1339673755198158349044581307228491536", ((b << 32) / p).ToString());
Assert.AreEqual("1339673755198158349044581307228491536", (b * p >> 32).ToString());
Assert.AreEqual("1339673755198158349044581307228491536", ((b * p) >> 32).ToString());
}
[TestMethod]
@@ -1567,22 +1565,22 @@ namespace Renci.SshNet.Tests.Classes.Common
public void ToArray_Performance()
{
const int loopCount = 100000000;
var bigInteger = new BigInteger(huge_a);
var bigInteger = new BigInteger(Huge_a);
var stopWatch = new Stopwatch();
GC.Collect();
GC.WaitForFullGCComplete();
_ = GC.WaitForFullGCComplete();
stopWatch.Start();
for (var i = 0; i < loopCount; i++)
{
bigInteger.ToByteArray();
_ = bigInteger.ToByteArray();
}
GC.Collect();
GC.WaitForFullGCComplete();
_ = GC.WaitForFullGCComplete();
stopWatch.Stop();
@@ -1599,17 +1597,17 @@ namespace Renci.SshNet.Tests.Classes.Common
var stopWatch = new Stopwatch();
GC.Collect();
GC.WaitForFullGCComplete();
_ = GC.WaitForFullGCComplete();
stopWatch.Start();
for (var i = 0; i < loopCount; i++)
{
new BigInteger(huge_a);
_ = new BigInteger(Huge_a);
}
GC.Collect();
GC.WaitForFullGCComplete();
_ = GC.WaitForFullGCComplete();
stopWatch.Stop();
@@ -1656,8 +1654,7 @@ namespace Renci.SshNet.Tests.Classes.Common
public void Random()
{
var max = "26432534714839143538998938508341375449389492936207135611931371046236385860280414659368073862189301615603000443463893527273703804361856647266218472759410964268979057798543462774631912259980510080575520846081682603934587649566608158932346151315049355432937004801361578344502537300865702429436253728164365180058583916866804254965536833106467354901266304654706123552932560896874808786957654734387252964281680963136344135750381838556467139236094522411774117748615141352874979928570068255439327082539676660277104989857941859821396157749462154431239343148671646397611770487668571604363151098131876313773395912355145689712506";
BigInteger maxBigInt;
Assert.IsTrue(BigInteger.TryParse(max, NumberStyles.Number, NumberFormatInfo.CurrentInfo, out maxBigInt));
Assert.IsTrue(BigInteger.TryParse(max, NumberStyles.Number, NumberFormatInfo.CurrentInfo, out var maxBigInt));
var random = BigInteger.One;
while (random <= BigInteger.One || random >= maxBigInt)
@@ -1670,8 +1667,7 @@ namespace Renci.SshNet.Tests.Classes.Common
public void TestClientExhcangeGenerationItem130()
{
var test = "1090748135619415929450294929359784500348155124953172211774101106966150168922785639028532473848836817769712164169076432969224698752674677662739994265785437233596157045970922338040698100507861033047312331823982435279475700199860971612732540528796554502867919746776983759391475987142521315878719577519148811830879919426939958487087540965716419167467499326156226529675209172277001377591248147563782880558861083327174154014975134893125116015776318890295960698011614157721282527539468816519319333337503114777192360412281721018955834377615480468479252748867320362385355596601795122806756217713579819870634321561907813255153703950795271232652404894983869492174481652303803498881366210508647263668376514131031102336837488999775744046733651827239395353540348414872854639719294694323450186884189822544540647226987292160693184734654941906936646576130260972193280317171696418971553954161446191759093719524951116705577362073481319296041201283516154269044389257727700289684119460283480452306204130024913879981135908026983868205969318167819680850998649694416907952712904962404937775789698917207356355227455066183815847669135530549755439819480321732925869069136146085326382334628745456398071603058051634209386708703306545903199608523824513729625136659128221100967735450519952404248198262813831097374261650380017277916975324134846574681307337017380830353680623216336949471306191686438249305686413380231046096450953594089375540285037292470929395114028305547452584962074309438151825437902976012891749355198678420603722034900311364893046495761404333938686140037848030916292543273684533640032637639100774502371542479302473698388692892420946478947733800387782741417786484770190108867879778991633218628640533982619322466154883011452291890252336487236086654396093853898628805813177559162076363154436494477507871294119841637867701722166609831201845484078070518041336869808398454625586921201308185638888082699408686536045192649569198110353659943111802300636106509865023943661829436426563007917282050894429388841748885398290707743052973605359277515749619730823773215894755121761467887865327707115573804264519206349215850195195364813387526811742474131549802130246506341207020335797706780705406945275438806265978516209706795702579244075380490231741030862614968783306207869687868108423639971983209077624758080499988275591392787267627182442892809646874228263172435642368588260139161962836121481966092745325488641054238839295138992979335446110090325230955276870524611359124918392740353154294858383359";
BigInteger prime;
BigInteger.TryParse(test, NumberStyles.Number, NumberFormatInfo.CurrentInfo, out prime);
_ = BigInteger.TryParse(test, NumberStyles.Number, NumberFormatInfo.CurrentInfo, out var prime);
BigInteger group = 2;
var bitLength = prime.BitLength;
@@ -1683,15 +1679,15 @@ namespace Renci.SshNet.Tests.Classes.Common
//clientExchangeValue = BigInteger.ModPow(group, randomValue, prime);
clientExchangeValue = (group ^ randomValue) % prime;
} while (clientExchangeValue < 1 || clientExchangeValue > (prime - 1));
}
while (clientExchangeValue < 1 || clientExchangeValue > (prime - 1));
}
[TestMethod]
public void TestClientExhcangeGenerationGroup1()
{
var test = "00FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF";
BigInteger prime;
BigInteger.TryParse(test, NumberStyles.AllowHexSpecifier, NumberFormatInfo.CurrentInfo, out prime);
_ = BigInteger.TryParse(test, NumberStyles.AllowHexSpecifier, NumberFormatInfo.CurrentInfo, out var prime);
BigInteger group = 2;
var bitLength = prime.BitLength;
@@ -1703,15 +1699,15 @@ namespace Renci.SshNet.Tests.Classes.Common
//clientExchangeValue = BigInteger.ModPow(group, randomValue, prime);
clientExchangeValue = (group ^ randomValue) % prime;
} while (clientExchangeValue < 1 || clientExchangeValue > (prime - 1));
}
while (clientExchangeValue < 1 || clientExchangeValue > (prime - 1));
}
[TestMethod]
public void TestClientExhcangeGenerationGroup14()
{
var test = "00FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF";
BigInteger prime;
BigInteger.TryParse(test, NumberStyles.AllowHexSpecifier, NumberFormatInfo.CurrentInfo, out prime);
_ = BigInteger.TryParse(test, NumberStyles.AllowHexSpecifier, NumberFormatInfo.CurrentInfo, out var prime);
BigInteger group = 2;
var bitLength = prime.BitLength;
@@ -1723,7 +1719,8 @@ namespace Renci.SshNet.Tests.Classes.Common
//clientExchangeValue = BigInteger.ModPow(group, randomValue, prime);
clientExchangeValue = (group ^ randomValue) % prime;
} while (clientExchangeValue < 1 || clientExchangeValue > (prime - 1));
}
while (clientExchangeValue < 1 || clientExchangeValue > (prime - 1));
}
private static void AssertEqual(byte[] a, byte[] b)
@@ -4,10 +4,10 @@ using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Common
{
/// <summary>
/// Provides data for <see cref="Renci.SshNet.Channels.Channel.OpenFailed"/> event.
/// Provides data for <see cref="SshNet.Channels.ClientChannel.OpenFailed"/> event.
/// </summary>
[TestClass]
public class ChannelOpenFailedEventArgsTest : TestBase
{
}
}
}
@@ -1,6 +1,7 @@
using System;
using System.Diagnostics;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Renci.SshNet.Tests.Classes.Common
@@ -71,7 +72,7 @@ namespace Renci.SshNet.Tests.Classes.Common
try
{
countdownEvent.Signal();
_ = countdownEvent.Signal();
Assert.Fail();
}
catch (InvalidOperationException)
@@ -95,7 +96,9 @@ namespace Renci.SshNet.Tests.Classes.Common
var expectedSignalCount = _random.Next(5, 20);
for (var i = 0; i < (expectedSignalCount - 1); i++)
{
countdownEvent.AddCount();
}
var threads = new Thread[expectedSignalCount];
for (var i = 0; i < expectedSignalCount; i++)
@@ -103,8 +106,8 @@ namespace Renci.SshNet.Tests.Classes.Common
threads[i] = new Thread(() =>
{
Thread.Sleep(sleep);
Interlocked.Increment(ref signalCount);
countdownEvent.Signal();
_ = Interlocked.Increment(ref signalCount);
_ = countdownEvent.Signal();
});
threads[i].Start();
}
@@ -135,17 +138,19 @@ namespace Renci.SshNet.Tests.Classes.Common
var expectedSignalCount = _random.Next(5, 20);
for (var i = 0; i < (expectedSignalCount - 1); i++)
{
countdownEvent.AddCount();
}
var threads = new Thread[expectedSignalCount];
for (var i = 0; i < expectedSignalCount; i++)
{
threads[i] = new Thread(() =>
{
Thread.Sleep(sleep);
Interlocked.Increment(ref signalCount);
countdownEvent.Signal();
});
{
Thread.Sleep(sleep);
_ = Interlocked.Increment(ref signalCount);
_ = countdownEvent.Signal();
});
threads[i].Start();
}
@@ -175,17 +180,19 @@ namespace Renci.SshNet.Tests.Classes.Common
var expectedSignalCount = _random.Next(5, 20);
for (var i = 0; i < (expectedSignalCount - 1); i++)
{
countdownEvent.AddCount();
}
var threads = new Thread[expectedSignalCount];
for (var i = 0; i < expectedSignalCount; i++)
{
threads[i] = new Thread(() =>
{
Thread.Sleep(sleep);
countdownEvent.Signal();
Interlocked.Increment(ref signalCount);
});
{
Thread.Sleep(sleep);
_ = countdownEvent.Signal();
_ = Interlocked.Increment(ref signalCount);
});
threads[i].Start();
}
@@ -198,7 +205,7 @@ namespace Renci.SshNet.Tests.Classes.Common
Assert.IsFalse(countdownEvent.IsSet);
Assert.IsFalse(countdownEvent.WaitHandle.WaitOne(0));
countdownEvent.Wait(Session.InfiniteTimeSpan);
_ = countdownEvent.Wait(Session.InfiniteTimeSpan);
countdownEvent.Dispose();
}
@@ -225,17 +232,19 @@ namespace Renci.SshNet.Tests.Classes.Common
var expectedSignalCount = _random.Next(5, 20);
for (var i = 0; i < (expectedSignalCount - 1); i++)
{
countdownEvent.AddCount();
}
var threads = new Thread[expectedSignalCount];
for (var i = 0; i < expectedSignalCount; i++)
{
threads[i] = new Thread(() =>
{
Thread.Sleep(sleep);
Interlocked.Increment(ref signalCount);
countdownEvent.Signal();
});
{
Thread.Sleep(sleep);
_ = Interlocked.Increment(ref signalCount);
_ = countdownEvent.Signal();
});
threads[i].Start();
}
@@ -265,17 +274,19 @@ namespace Renci.SshNet.Tests.Classes.Common
var expectedSignalCount = _random.Next(5, 20);
for (var i = 0; i < (expectedSignalCount - 1); i++)
{
countdownEvent.AddCount();
}
var threads = new Thread[expectedSignalCount];
for (var i = 0; i < expectedSignalCount; i++)
{
threads[i] = new Thread(() =>
{
Thread.Sleep(sleep);
Interlocked.Increment(ref signalCount);
countdownEvent.Signal();
});
{
Thread.Sleep(sleep);
_ = Interlocked.Increment(ref signalCount);
_ = countdownEvent.Signal();
});
threads[i].Start();
}
@@ -305,17 +316,19 @@ namespace Renci.SshNet.Tests.Classes.Common
var expectedSignalCount = _random.Next(5, 20);
for (var i = 0; i < (expectedSignalCount - 1); i++)
{
countdownEvent.AddCount();
}
var threads = new Thread[expectedSignalCount];
for (var i = 0; i < expectedSignalCount; i++)
{
threads[i] = new Thread(() =>
{
Thread.Sleep(sleep);
countdownEvent.Signal();
Interlocked.Increment(ref signalCount);
});
{
Thread.Sleep(sleep);
_ = countdownEvent.Signal();
_ = Interlocked.Increment(ref signalCount);
});
threads[i].Start();
}
@@ -328,7 +341,7 @@ namespace Renci.SshNet.Tests.Classes.Common
Assert.IsFalse(countdownEvent.IsSet);
Assert.IsFalse(countdownEvent.WaitHandle.WaitOne(0));
countdownEvent.Wait(Session.InfiniteTimeSpan);
_ = countdownEvent.Wait(Session.InfiniteTimeSpan);
countdownEvent.Dispose();
}
@@ -26,7 +26,7 @@ namespace Renci.SshNet.Tests.Classes.Common
try
{
Extensions.IsEqualTo(left, right);
_ = Extensions.IsEqualTo(left, right);
Assert.Fail();
}
catch (ArgumentNullException ex)
@@ -44,7 +44,7 @@ namespace Renci.SshNet.Tests.Classes.Common
try
{
Extensions.IsEqualTo(left, right);
_ = Extensions.IsEqualTo(left, right);
Assert.Fail();
}
catch (ArgumentNullException ex)
@@ -62,7 +62,7 @@ namespace Renci.SshNet.Tests.Classes.Common
try
{
Extensions.IsEqualTo(left, right);
_ = Extensions.IsEqualTo(left, right);
Assert.Fail();
}
catch (ArgumentNullException ex)
@@ -157,7 +157,7 @@ namespace Renci.SshNet.Tests.Classes.Common
for (var i = 0; i < runs; i++)
{
Extensions.IsEqualTo(left, right);
_ = Extensions.IsEqualTo(left, right);
}
GC.Collect();
@@ -1,6 +1,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Renci.SshNet.Common;
namespace Renci.SshNet.Tests.Classes.Common
@@ -13,7 +14,7 @@ namespace Renci.SshNet.Tests.Classes.Common
public void ShouldReturnNotPadded()
{
byte[] value = {0x0a, 0x0d};
byte[] padded = value.Pad(2);
var padded = value.Pad(2);
Assert.AreEqual(value, padded);
Assert.AreEqual(value.Length, padded.Length);
}
@@ -22,7 +23,7 @@ namespace Renci.SshNet.Tests.Classes.Common
public void ShouldReturnPadded()
{
byte[] value = { 0x0a, 0x0d };
byte[] padded = value.Pad(3);
var padded = value.Pad(3);
Assert.AreEqual(value.Length + 1, padded.Length);
Assert.AreEqual(0x00, padded[0]);
Assert.AreEqual(0x0a, padded[1]);
@@ -1,12 +1,10 @@
using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Renci.SshNet.Common;
namespace Renci.SshNet.Tests.Classes.Common
{
[TestClass]
[SuppressMessage("ReSharper", "InvokeAsExtensionMethod")]
public class ExtensionsTest_ToBigInteger2
{
[TestMethod]
@@ -15,7 +15,7 @@ namespace Renci.SshNet.Tests.Classes.Common
try
{
PacketDump.Create(data, 0);
_ = PacketDump.Create(data, 0);
Assert.Fail();
}
catch (ArgumentNullException ex)
@@ -32,7 +32,7 @@ namespace Renci.SshNet.Tests.Classes.Common
try
{
PacketDump.Create(data, -1);
_ =PacketDump.Create(data, -1);
Assert.Fail();
}
catch (ArgumentOutOfRangeException ex)
@@ -1,7 +1,9 @@
using System;
using System.IO;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Renci.SshNet.Common;
using Renci.SshNet.Tests.Common;
@@ -25,7 +27,7 @@ namespace Renci.SshNet.Tests.Classes.Common
Assert.AreEqual(stream.Length, testBuffer.Length);
stream.Read(outputBuffer, 0, outputBuffer.Length);
_ = stream.Read(outputBuffer, 0, outputBuffer.Length);
Assert.AreEqual(stream.Length, 0);
@@ -44,9 +46,9 @@ namespace Renci.SshNet.Tests.Classes.Common
{
stream.Write(testBuffer, 0, testBuffer.Length);
Assert.AreEqual(stream.Length, testBuffer.Length);
stream.ReadByte();
_ = stream.ReadByte();
Assert.AreEqual(stream.Length, testBuffer.Length - 1);
stream.ReadByte();
_ = stream.ReadByte();
Assert.AreEqual(stream.Length, testBuffer.Length - 2);
}
}
@@ -92,7 +94,7 @@ namespace Renci.SshNet.Tests.Classes.Common
try
{
target.Seek(offset, origin);
_ = target.Seek(offset, origin);
Assert.Fail();
}
catch (NotSupportedException)
@@ -169,9 +171,9 @@ namespace Renci.SshNet.Tests.Classes.Common
Assert.AreEqual(2L, target.Length);
target.WriteByte(0x0a);
Assert.AreEqual(3L, target.Length);
target.Read(new byte[2], 0, 2);
_ = target.Read(new byte[2], 0, 2);
Assert.AreEqual(1L, target.Length);
target.ReadByte();
_ = target.ReadByte();
Assert.AreEqual(0L, target.Length);
}
@@ -195,7 +197,7 @@ namespace Renci.SshNet.Tests.Classes.Common
Assert.AreEqual(0, target.Position);
target.WriteByte(0x0a);
Assert.AreEqual(0, target.Position);
target.ReadByte();
_ = target.ReadByte();
Assert.AreEqual(0, target.Position);
}
@@ -214,4 +216,4 @@ namespace Renci.SshNet.Tests.Classes.Common
}
}
}
}
}
@@ -34,7 +34,7 @@ namespace Renci.SshNet.Tests.Classes.Common
_pipeStream.Close();
// give async read time to complete
_readThread.Join(100);
_ = _readThread.Join(100);
}
[TestMethod]
@@ -45,7 +45,7 @@ namespace Renci.SshNet.Tests.Classes.Common
_pipeStream.Close();
// give write time to complete
_writehread.Join(100);
_ = _writehread.Join(100);
}
[TestMethod]
@@ -30,7 +30,7 @@ namespace Renci.SshNet.Tests.Classes.Common
_readThread.Start();
// ensure we've started reading
_readThread.Join(50);
_ = _readThread.Join(50);
}
protected override void Act()
@@ -38,7 +38,7 @@ namespace Renci.SshNet.Tests.Classes.Common
_pipeStream.Flush();
// give async read time to complete
_readThread.Join(100);
_ = _readThread.Join(100);
}
[TestMethod]
@@ -34,7 +34,7 @@ namespace Renci.SshNet.Tests.Classes.Common
_pipeStream.Flush();
// give async read time to complete
_readThread.Join(100);
_ = _readThread.Join(100);
}
[TestMethod]
@@ -18,7 +18,7 @@ namespace Renci.SshNet.Tests.Classes.Common
{
try
{
new PortForwardEventArgs(null, 80);
_ = new PortForwardEventArgs(null, 80);
}
catch (ArgumentNullException ex)
{
@@ -54,7 +54,7 @@ namespace Renci.SshNet.Tests.Classes.Common
try
{
new PortForwardEventArgs(Resources.HOST, port);
_ = new PortForwardEventArgs(Resources.HOST, port);
Assert.Fail();
}
catch (ArgumentOutOfRangeException ex)
@@ -64,4 +64,4 @@ namespace Renci.SshNet.Tests.Classes.Common
}
}
}
}
}
@@ -15,7 +15,7 @@ namespace Renci.SshNet.Tests.Classes.Common
try
{
PosixPath.CreateAbsoluteOrRelativeFilePath(path);
_ = PosixPath.CreateAbsoluteOrRelativeFilePath(path);
Assert.Fail();
}
catch (ArgumentNullException ex)
@@ -32,7 +32,7 @@ namespace Renci.SshNet.Tests.Classes.Common
try
{
PosixPath.CreateAbsoluteOrRelativeFilePath(path);
_ = PosixPath.CreateAbsoluteOrRelativeFilePath(path);
Assert.Fail();
}
catch (ArgumentException ex)
@@ -14,7 +14,7 @@ namespace Renci.SshNet.Tests.Classes.Common
try
{
PosixPath.GetDirectoryName(path);
_ = PosixPath.GetDirectoryName(path);
Assert.Fail();
}
catch (ArgumentNullException ex)
@@ -14,7 +14,7 @@ namespace Renci.SshNet.Tests.Classes.Common
try
{
PosixPath.GetFileName(path);
_ = PosixPath.GetFileName(path);
Assert.Fail();
}
catch (ArgumentNullException ex)
@@ -67,12 +67,11 @@ namespace Renci.SshNet.Tests.Classes.Common
Assert.IsTrue(watch.ElapsedMilliseconds < 50);
var releaseThread = new Thread(
() =>
{
Thread.Sleep(sleepTime);
target.Release();
});
var releaseThread = new Thread(() =>
{
Thread.Sleep(sleepTime);
_ = target.Release();
});
releaseThread.Start();
target.Wait();
@@ -1,6 +1,8 @@
using System;
using System.Runtime.Serialization;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Renci.SshNet.Common;
using Renci.SshNet.Messages.Transport;
using Renci.SshNet.Tests.Common;
@@ -20,7 +22,7 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void SshConnectionExceptionConstructorTest()
{
SshConnectionException target = new SshConnectionException();
var target = new SshConnectionException();
Assert.Inconclusive("TODO: Implement code to verify target");
}
@@ -30,8 +32,8 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void SshConnectionExceptionConstructorTest1()
{
string message = string.Empty; // TODO: Initialize to an appropriate value
SshConnectionException target = new SshConnectionException(message);
var message = string.Empty; // TODO: Initialize to an appropriate value
var target = new SshConnectionException(message);
Assert.Inconclusive("TODO: Implement code to verify target");
}
@@ -41,9 +43,9 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void SshConnectionExceptionConstructorTest2()
{
string message = string.Empty; // TODO: Initialize to an appropriate value
DisconnectReason disconnectReasonCode = new DisconnectReason(); // TODO: Initialize to an appropriate value
SshConnectionException target = new SshConnectionException(message, disconnectReasonCode);
var message = string.Empty; // TODO: Initialize to an appropriate value
var disconnectReasonCode = new DisconnectReason(); // TODO: Initialize to an appropriate value
var target = new SshConnectionException(message, disconnectReasonCode);
Assert.Inconclusive("TODO: Implement code to verify target");
}
@@ -53,10 +55,10 @@ namespace Renci.SshNet.Tests.Classes.Common
[TestMethod]
public void SshConnectionExceptionConstructorTest3()
{
string message = string.Empty; // TODO: Initialize to an appropriate value
DisconnectReason disconnectReasonCode = new DisconnectReason(); // TODO: Initialize to an appropriate value
var message = string.Empty; // TODO: Initialize to an appropriate value
var disconnectReasonCode = new DisconnectReason(); // TODO: Initialize to an appropriate value
Exception inner = null; // TODO: Initialize to an appropriate value
SshConnectionException target = new SshConnectionException(message, disconnectReasonCode, inner);
var target = new SshConnectionException(message, disconnectReasonCode, inner);
Assert.Inconclusive("TODO: Implement code to verify target");
}
@@ -67,9 +69,9 @@ namespace Renci.SshNet.Tests.Classes.Common
[Ignore] // placeholder for actual test
public void GetObjectDataTest()
{
SshConnectionException target = new SshConnectionException(); // TODO: Initialize to an appropriate value
var target = new SshConnectionException(); // TODO: Initialize to an appropriate value
SerializationInfo info = null; // TODO: Initialize to an appropriate value
StreamingContext context = new StreamingContext(); // TODO: Initialize to an appropriate value
var context = new StreamingContext(); // TODO: Initialize to an appropriate value
target.GetObjectData(info, context);
Assert.Inconclusive("A method that does not return a value cannot be verified.");
}
@@ -1,7 +1,6 @@
using Renci.SshNet.Compression;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Renci.SshNet;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Renci.SshNet.Compression;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Compression
@@ -20,7 +19,7 @@ namespace Renci.SshNet.Tests.Classes.Compression
[TestMethod()]
public void ZlibOpenSshConstructorTest()
{
ZlibOpenSsh target = new ZlibOpenSsh();
var target = new ZlibOpenSsh();
Assert.Inconclusive("TODO: Implement code to verify target");
}
@@ -30,7 +29,7 @@ namespace Renci.SshNet.Tests.Classes.Compression
[TestMethod()]
public void InitTest()
{
ZlibOpenSsh target = new ZlibOpenSsh(); // TODO: Initialize to an appropriate value
var target = new ZlibOpenSsh(); // TODO: Initialize to an appropriate value
Session session = null; // TODO: Initialize to an appropriate value
target.Init(session);
Assert.Inconclusive("A method that does not return a value cannot be verified.");
@@ -42,9 +41,8 @@ namespace Renci.SshNet.Tests.Classes.Compression
[TestMethod()]
public void NameTest()
{
ZlibOpenSsh target = new ZlibOpenSsh(); // TODO: Initialize to an appropriate value
string actual;
actual = target.Name;
var target = new ZlibOpenSsh(); // TODO: Initialize to an appropriate value
var actual = target.Name;
Assert.Inconclusive("Verify the correctness of this test method.");
}
}
@@ -1,11 +1,12 @@
using Renci.SshNet.Compression;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.IO;
using Renci.SshNet.Compression;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Compression
{
{
/// <summary>
///This is a test class for ZlibStreamTest and is intended
///to contain all ZlibStreamTest Unit Tests
@@ -21,8 +22,8 @@ namespace Renci.SshNet.Tests.Classes.Compression
public void ZlibStreamConstructorTest()
{
Stream stream = null; // TODO: Initialize to an appropriate value
CompressionMode mode = new CompressionMode(); // TODO: Initialize to an appropriate value
ZlibStream target = new ZlibStream(stream, mode);
var mode = new CompressionMode(); // TODO: Initialize to an appropriate value
var target = new ZlibStream(stream, mode);
Assert.Inconclusive("TODO: Implement code to verify target");
}
@@ -34,11 +35,11 @@ namespace Renci.SshNet.Tests.Classes.Compression
public void WriteTest()
{
Stream stream = null; // TODO: Initialize to an appropriate value
CompressionMode mode = new CompressionMode(); // TODO: Initialize to an appropriate value
ZlibStream target = new ZlibStream(stream, mode); // TODO: Initialize to an appropriate value
var mode = new CompressionMode(); // TODO: Initialize to an appropriate value
var target = new ZlibStream(stream, 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
var offset = 0; // TODO: Initialize to an appropriate value
var 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.");
}
@@ -1,7 +1,7 @@
using Moq;
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
using System.Net;
namespace Renci.SshNet.Tests.Classes.Connection
{
@@ -1,11 +1,12 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using System;
using System;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -30,18 +31,15 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_clientSocket != null)
{
_clientSocket.Dispose();
}
_clientSocket?.Dispose();
}
protected override void Act()
@@ -50,7 +48,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (SocketException ex)
@@ -86,7 +84,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_clientSocket.Receive(new byte[0]);
_ = _clientSocket.Receive(new byte[0]);
Assert.Fail();
}
catch (ObjectDisposedException)
@@ -1,12 +1,13 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
@@ -41,23 +42,16 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_server != null)
{
_server.Dispose();
}
if (_clientSocket != null)
{
_clientSocket.Dispose();
}
_server?.Dispose();
_clientSocket?.Dispose();
}
protected override void Act()
@@ -1,6 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using System.Net.Sockets;
using System.Net.Sockets;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Renci.SshNet.Tests.Classes.Connection
{
@@ -22,7 +22,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (SocketException ex)
@@ -1,13 +1,15 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Diagnostics;
using System.Globalization;
using System.Net;
using System.Net.Sockets;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -34,18 +36,15 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_clientSocket != null)
{
_clientSocket.Dispose();
}
_clientSocket?.Dispose();
}
protected override void Act()
@@ -54,7 +53,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (SshOperationTimeoutException ex)
@@ -91,7 +90,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_clientSocket.Receive(new byte[0]);
_ = _clientSocket.Receive(new byte[0]);
Assert.Fail();
}
catch (ObjectDisposedException)
@@ -1,6 +1,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using System;
using System.Diagnostics;
using System.Net;
@@ -28,8 +29,10 @@ namespace Renci.SshNet.Tests.Classes.Connection
8122,
"proxyUser",
"proxyPwd",
new KeyboardInteractiveAuthenticationMethod("user"));
_connectionInfo.Timeout = TimeSpan.FromMilliseconds(5000);
new KeyboardInteractiveAuthenticationMethod("user"))
{
Timeout = TimeSpan.FromMilliseconds(5000)
};
_stopWatch = new Stopwatch();
_actualException = null;
@@ -38,18 +41,15 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_clientSocket != null)
{
_clientSocket.Dispose();
}
_clientSocket?.Dispose();
}
protected override void Act()
@@ -58,7 +58,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (SocketException ex)
@@ -94,7 +94,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_clientSocket.Receive(new byte[0]);
_ = _clientSocket.Receive(new byte[0]);
Assert.Fail();
}
catch (ObjectDisposedException)
@@ -30,8 +30,10 @@ namespace Renci.SshNet.Tests.Classes.Connection
8122,
"proxyUser",
"proxyPwd",
new KeyboardInteractiveAuthenticationMethod("user"));
_connectionInfo.Timeout = TimeSpan.FromMilliseconds(100);
new KeyboardInteractiveAuthenticationMethod("user"))
{
Timeout = TimeSpan.FromMilliseconds(100)
};
_actualException = null;
_clientSocket = SocketFactory.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
@@ -47,30 +49,23 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
if (_clientSocket != null)
{
_clientSocket.Dispose();
}
_proxyServer?.Dispose();
_clientSocket?.Dispose();
}
protected override void Act()
{
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (ProxyException ex)
@@ -101,7 +96,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_clientSocket.Receive(new byte[0]);
_ = _clientSocket.Receive(new byte[0]);
Assert.Fail();
}
catch (ObjectDisposedException)
@@ -29,7 +29,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (SocketException ex)
@@ -1,7 +1,4 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net;
@@ -9,6 +6,12 @@ using System.Net.Sockets;
using System.Text;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -34,8 +37,10 @@ namespace Renci.SshNet.Tests.Classes.Connection
8122,
"proxyUser",
string.Empty,
new KeyboardInteractiveAuthenticationMethod("user"));
_connectionInfo.Timeout = TimeSpan.FromMilliseconds(20);
new KeyboardInteractiveAuthenticationMethod("user"))
{
Timeout = TimeSpan.FromMilliseconds(20)
};
_expectedHttpRequest = string.Format("CONNECT {0}:{1} HTTP/1.0{2}" +
"Proxy-Authorization: Basic cHJveHlVc2VyOg=={2}{2}",
_connectionInfo.Host,
@@ -49,13 +54,14 @@ namespace Renci.SshNet.Tests.Classes.Connection
_proxyServer.Disconnected += (socket) => _disconnected = true;
_proxyServer.Connected += socket =>
{
socket.Send(Encoding.ASCII.GetBytes("\r\n"));
socket.Send(Encoding.ASCII.GetBytes("SSH.NET\r\n"));
socket.Send(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
socket.Send(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
socket.Send(Encoding.ASCII.GetBytes("\r\n"));
socket.Send(Encoding.ASCII.GetBytes("SSH4EVER"));
socket.Shutdown(SocketShutdown.Send);
_ = socket.Send(Encoding.ASCII.GetBytes("\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("SSH.NET\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("SSH4EVER"));
socket.Shutdown(SocketShutdown.Send);
};
_proxyServer.BytesReceived += (bytesReceived, socket) =>
{
@@ -66,18 +72,15 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
_proxyServer?.Dispose();
if (_clientSocket != null)
{
@@ -34,8 +34,10 @@ namespace Renci.SshNet.Tests.Classes.Connection
8122,
"proxyUser",
null,
new KeyboardInteractiveAuthenticationMethod("user"));
_connectionInfo.Timeout = TimeSpan.FromMilliseconds(20);
new KeyboardInteractiveAuthenticationMethod("user"))
{
Timeout = TimeSpan.FromMilliseconds(20)
};
_expectedHttpRequest = string.Format("CONNECT {0}:{1} HTTP/1.0{2}" +
"Proxy-Authorization: Basic cHJveHlVc2VyOg=={2}{2}",
_connectionInfo.Host,
@@ -49,12 +51,13 @@ namespace Renci.SshNet.Tests.Classes.Connection
_proxyServer.Disconnected += (socket) => _disconnected = true;
_proxyServer.Connected += socket =>
{
socket.Send(Encoding.ASCII.GetBytes("\r\n"));
socket.Send(Encoding.ASCII.GetBytes("SSH.NET\r\n"));
socket.Send(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
socket.Send(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
socket.Send(Encoding.ASCII.GetBytes("\r\n"));
socket.Send(Encoding.ASCII.GetBytes("SSH4EVER"));
_ = socket.Send(Encoding.ASCII.GetBytes("\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("SSH.NET\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("SSH4EVER"));
socket.Shutdown(SocketShutdown.Send);
};
_proxyServer.BytesReceived += (bytesReceived, socket) =>
@@ -66,18 +69,15 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
_proxyServer?.Dispose();
if (_clientSocket != null)
{
@@ -1,14 +1,17 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -33,8 +36,10 @@ namespace Renci.SshNet.Tests.Classes.Connection
8122,
"proxyUser",
"proxyPwd",
new KeyboardInteractiveAuthenticationMethod("user"));
_connectionInfo.Timeout = TimeSpan.FromMilliseconds(100);
new KeyboardInteractiveAuthenticationMethod("user"))
{
Timeout = TimeSpan.FromMilliseconds(100)
};
_bytesReceivedByProxy = new List<byte>();
_actualException = null;
@@ -46,7 +51,8 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
if (_bytesReceivedByProxy.Count == 0)
{
socket.Send(Encoding.ASCII.GetBytes("Whatever\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("Whatever\r\n"));
socket.Shutdown(SocketShutdown.Send);
}
@@ -57,25 +63,22 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
_proxyServer?.Dispose();
}
protected override void Act()
{
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (ProxyException ex)
@@ -106,7 +109,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_clientSocket.Receive(new byte[0]);
_ = _clientSocket.Receive(new byte[0]);
Assert.Fail();
}
catch (ObjectDisposedException)
@@ -1,7 +1,4 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net;
@@ -9,6 +6,12 @@ using System.Net.Sockets;
using System.Text;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -34,8 +37,10 @@ namespace Renci.SshNet.Tests.Classes.Connection
8122,
"proxyUser",
"proxyPwd",
new KeyboardInteractiveAuthenticationMethod("user"));
_connectionInfo.Timeout = TimeSpan.FromMilliseconds(20);
new KeyboardInteractiveAuthenticationMethod("user"))
{
Timeout = TimeSpan.FromMilliseconds(20)
};
_expectedHttpRequest = string.Format("CONNECT {0}:{1} HTTP/1.0{2}" +
"Proxy-Authorization: Basic cHJveHlVc2VyOnByb3h5UHdk{2}{2}",
_connectionInfo.Host,
@@ -56,12 +61,13 @@ namespace Renci.SshNet.Tests.Classes.Connection
// it sends the CONNECT request
if (_bytesReceivedByProxy.Count == _expectedHttpRequest.Length)
{
socket.Send(Encoding.ASCII.GetBytes("\r\n"));
socket.Send(Encoding.ASCII.GetBytes("SSH.NET\r\n"));
socket.Send(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
socket.Send(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
socket.Send(Encoding.ASCII.GetBytes("\r\n"));
socket.Send(Encoding.ASCII.GetBytes("SSH4EVER"));
_ = socket.Send(Encoding.ASCII.GetBytes("\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("SSH.NET\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("SSH4EVER"));
socket.Shutdown(SocketShutdown.Send);
}
};
@@ -70,18 +76,15 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
_proxyServer?.Dispose();
if (_clientSocket != null)
{
@@ -1,7 +1,4 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net;
@@ -9,6 +6,12 @@ using System.Net.Sockets;
using System.Text;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -34,8 +37,10 @@ namespace Renci.SshNet.Tests.Classes.Connection
8122,
"proxyUser",
"proxyPwd",
new KeyboardInteractiveAuthenticationMethod("user"));
_connectionInfo.Timeout = TimeSpan.FromMilliseconds(20);
new KeyboardInteractiveAuthenticationMethod("user"))
{
Timeout = TimeSpan.FromMilliseconds(20)
};
_expectedHttpRequest = string.Format("CONNECT {0}:{1} HTTP/1.0{2}" +
"Proxy-Authorization: Basic cHJveHlVc2VyOnByb3h5UHdk{2}{2}",
_connectionInfo.Host,
@@ -56,12 +61,13 @@ namespace Renci.SshNet.Tests.Classes.Connection
// it sends the CONNECT request
if (_bytesReceivedByProxy.Count == _expectedHttpRequest.Length)
{
socket.Send(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
socket.Send(Encoding.ASCII.GetBytes("Content-Length: 10\r\n"));
socket.Send(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
socket.Send(Encoding.ASCII.GetBytes("\r\n"));
socket.Send(Encoding.ASCII.GetBytes("TEEN_BYTES"));
socket.Send(Encoding.ASCII.GetBytes("!666!"));
_ = socket.Send(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("Content-Length: 10\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("TEEN_BYTES"));
_ = socket.Send(Encoding.ASCII.GetBytes("!666!"));
socket.Shutdown(SocketShutdown.Send);
}
};
@@ -70,18 +76,15 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
_proxyServer?.Dispose();
if (_clientSocket != null)
{
@@ -34,8 +34,10 @@ namespace Renci.SshNet.Tests.Classes.Connection
8122,
"proxyUser",
"proxyPwd",
new KeyboardInteractiveAuthenticationMethod("user"));
_connectionInfo.Timeout = TimeSpan.FromMilliseconds(20);
new KeyboardInteractiveAuthenticationMethod("user"))
{
Timeout = TimeSpan.FromMilliseconds(20)
};
_expectedHttpRequest = string.Format("CONNECT {0}:{1} HTTP/1.0{2}" +
"Proxy-Authorization: Basic cHJveHlVc2VyOnByb3h5UHdk{2}{2}",
_connectionInfo.Host,
@@ -56,10 +58,11 @@ namespace Renci.SshNet.Tests.Classes.Connection
// it sends the CONNECT request
if (_bytesReceivedByProxy.Count == _expectedHttpRequest.Length)
{
socket.Send(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
socket.Send(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
socket.Send(Encoding.ASCII.GetBytes("\r\n"));
socket.Send(Encoding.ASCII.GetBytes("SSH4EVER"));
_ = socket.Send(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("SSH4EVER"));
socket.Shutdown(SocketShutdown.Send);
}
};
@@ -68,18 +71,15 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
_proxyServer?.Dispose();
if (_clientSocket != null)
{
@@ -1,14 +1,17 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -33,8 +36,10 @@ namespace Renci.SshNet.Tests.Classes.Connection
8122,
"proxyUser",
"proxyPwd",
new KeyboardInteractiveAuthenticationMethod("user"));
_connectionInfo.Timeout = TimeSpan.FromMilliseconds(100);
new KeyboardInteractiveAuthenticationMethod("user"))
{
Timeout = TimeSpan.FromMilliseconds(100)
};
_bytesReceivedByProxy = new List<byte>();
_actualException = null;
@@ -46,7 +51,8 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
if (_bytesReceivedByProxy.Count == 0)
{
socket.Send(Encoding.ASCII.GetBytes("HTTP/1.0 404 I searched everywhere, really...\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("HTTP/1.0 404 I searched everywhere, really...\r\n"));
socket.Shutdown(SocketShutdown.Send);
}
@@ -57,25 +63,22 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
_proxyServer?.Dispose();
}
protected override void Act()
{
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (ProxyException ex)
@@ -106,7 +109,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_clientSocket.Receive(new byte[0]);
_ = _clientSocket.Receive(new byte[0]);
Assert.Fail();
}
catch (ObjectDisposedException)
@@ -1,7 +1,4 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net;
@@ -9,6 +6,12 @@ using System.Net.Sockets;
using System.Text;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -34,8 +37,10 @@ namespace Renci.SshNet.Tests.Classes.Connection
8122,
string.Empty,
"proxyPwd",
new KeyboardInteractiveAuthenticationMethod("user"));
_connectionInfo.Timeout = TimeSpan.FromMilliseconds(20);
new KeyboardInteractiveAuthenticationMethod("user"))
{
Timeout = TimeSpan.FromMilliseconds(20)
};
_expectedHttpRequest = string.Format("CONNECT {0}:{1} HTTP/1.0{2}{2}",
_connectionInfo.Host,
_connectionInfo.Port.ToString(CultureInfo.InvariantCulture),
@@ -55,12 +60,12 @@ namespace Renci.SshNet.Tests.Classes.Connection
// it sends the CONNECT request
if (_bytesReceivedByProxy.Count == _expectedHttpRequest.Length)
{
socket.Send(Encoding.ASCII.GetBytes("\r\n"));
socket.Send(Encoding.ASCII.GetBytes("SSH.NET\r\n"));
socket.Send(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
socket.Send(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
socket.Send(Encoding.ASCII.GetBytes("\r\n"));
socket.Send(Encoding.ASCII.GetBytes("SSH4EVER"));
_ = socket.Send(Encoding.ASCII.GetBytes("\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("SSH.NET\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("SSH4EVER"));
}
};
_proxyServer.Start();
@@ -68,23 +73,16 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
if (_clientSocket != null)
{
_clientSocket.Close();
}
_proxyServer?.Dispose();
_clientSocket?.Close();
}
protected override void Act()
@@ -1,7 +1,4 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net;
@@ -9,6 +6,12 @@ using System.Net.Sockets;
using System.Text;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -34,8 +37,10 @@ namespace Renci.SshNet.Tests.Classes.Connection
8122,
"user",
"pwd",
new KeyboardInteractiveAuthenticationMethod("user"));
_connectionInfo.Timeout = TimeSpan.FromMilliseconds(20);
new KeyboardInteractiveAuthenticationMethod("user"))
{
Timeout = TimeSpan.FromMilliseconds(20)
};
_expectedHttpRequest = string.Format("CONNECT {0}:{1} HTTP/1.0{2}" +
"Proxy-Authorization: Basic dXNlcjpwd2Q={2}{2}",
_connectionInfo.Host,
@@ -48,10 +53,10 @@ namespace Renci.SshNet.Tests.Classes.Connection
_proxyServer = new AsyncSocketListener(new IPEndPoint(IPAddress.Loopback, _connectionInfo.ProxyPort));
_proxyServer.Connected += (socket) =>
{
socket.Send(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
socket.Send(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
socket.Send(Encoding.ASCII.GetBytes("\r\n"));
socket.Send(Encoding.ASCII.GetBytes("SSH4EVER"));
_ = socket.Send(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("SSH4EVER"));
};
_proxyServer.Disconnected += (socket) => _disconnected = true;
_proxyServer.BytesReceived += (bytesReceived, socket) =>
@@ -63,18 +68,15 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
_proxyServer?.Dispose();
if (_clientSocket != null)
{
@@ -1,7 +1,4 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net;
@@ -9,6 +6,12 @@ using System.Net.Sockets;
using System.Text;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -34,8 +37,10 @@ namespace Renci.SshNet.Tests.Classes.Connection
8122,
null,
"proxyPwd",
new KeyboardInteractiveAuthenticationMethod("user"));
_connectionInfo.Timeout = TimeSpan.FromMilliseconds(20);
new KeyboardInteractiveAuthenticationMethod("user"))
{
Timeout = TimeSpan.FromMilliseconds(20)
};
_expectedHttpRequest = string.Format("CONNECT {0}:{1} HTTP/1.0{2}{2}",
_connectionInfo.Host,
_connectionInfo.Port.ToString(CultureInfo.InvariantCulture),
@@ -55,12 +60,12 @@ namespace Renci.SshNet.Tests.Classes.Connection
// it sends the CONNECT request
if (_bytesReceivedByProxy.Count == _expectedHttpRequest.Length)
{
socket.Send(Encoding.ASCII.GetBytes("\r\n"));
socket.Send(Encoding.ASCII.GetBytes("SSH.NET\r\n"));
socket.Send(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
socket.Send(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
socket.Send(Encoding.ASCII.GetBytes("\r\n"));
socket.Send(Encoding.ASCII.GetBytes("SSH4EVER"));
_ = socket.Send(Encoding.ASCII.GetBytes("\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("SSH.NET\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("SSH4EVER"));
}
};
_proxyServer.Start();
@@ -68,8 +73,8 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
@@ -82,10 +87,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
_clientSocket.Close();
}
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
_proxyServer?.Dispose();
}
protected override void Act()
@@ -1,12 +1,15 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using System;
using System;
using System.Diagnostics;
using System.Globalization;
using System.Net;
using System.Net.Sockets;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -31,8 +34,10 @@ namespace Renci.SshNet.Tests.Classes.Connection
8122,
"proxyUser",
"proxyPwd",
new KeyboardInteractiveAuthenticationMethod("user"));
_connectionInfo.Timeout = TimeSpan.FromMilliseconds(random.Next(50, 200));
new KeyboardInteractiveAuthenticationMethod("user"))
{
Timeout = TimeSpan.FromMilliseconds(random.Next(50, 200))
};
_stopWatch = new Stopwatch();
_actualException = null;
@@ -41,18 +46,15 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_clientSocket != null)
{
_clientSocket.Dispose();
}
_clientSocket?.Dispose();
}
protected override void Act()
@@ -61,7 +63,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (SshOperationTimeoutException ex)
@@ -98,7 +100,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_clientSocket.Receive(new byte[0]);
_ = _clientSocket.Receive(new byte[0]);
Assert.Fail();
}
catch (ObjectDisposedException)
@@ -1,9 +1,4 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
@@ -12,6 +7,14 @@ using System.Net.Sockets;
using System.Text;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -41,8 +44,10 @@ namespace Renci.SshNet.Tests.Classes.Connection
8122,
"proxyUser",
"proxyPwd",
new KeyboardInteractiveAuthenticationMethod("user"));
_connectionInfo.Timeout = TimeSpan.FromMilliseconds(random.Next(50, 200));
new KeyboardInteractiveAuthenticationMethod("user"))
{
Timeout = TimeSpan.FromMilliseconds(random.Next(50, 200))
};
_expectedHttpRequest = string.Format("CONNECT {0}:{1} HTTP/1.0{2}" +
"Proxy-Authorization: Basic cHJveHlVc2VyOnByb3h5UHdk{2}{2}",
_connectionInfo.Host,
@@ -63,11 +68,11 @@ namespace Renci.SshNet.Tests.Classes.Connection
// Force a timeout by sending less content than indicated by Content-Length header
if (_bytesReceivedByProxy.Count == _expectedHttpRequest.Length)
{
socket.Send(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
socket.Send(Encoding.ASCII.GetBytes("Content-Length: 10\r\n"));
socket.Send(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
socket.Send(Encoding.ASCII.GetBytes("\r\n"));
socket.Send(Encoding.ASCII.GetBytes("TOO_FEW"));
_ = socket.Send(Encoding.ASCII.GetBytes("HTTP/1.0 200 OK\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("Content-Length: 10\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("Content-Type: application/octet-stream\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("\r\n"));
_ = socket.Send(Encoding.ASCII.GetBytes("TOO_FEW"));
}
};
_proxyServer.Start();
@@ -78,23 +83,16 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_server != null)
{
_server.Dispose();
}
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
_server?.Dispose();
_proxyServer?.Dispose();
}
protected override void Act()
@@ -103,7 +101,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (SshOperationTimeoutException ex)
@@ -156,7 +154,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_clientSocket.Receive(new byte[0]);
_ = _clientSocket.Receive(new byte[0]);
Assert.Fail();
}
catch (ObjectDisposedException)
@@ -1,15 +1,18 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Diagnostics;
using System.Globalization;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -37,8 +40,10 @@ namespace Renci.SshNet.Tests.Classes.Connection
8122,
"proxyUser",
"proxyPwd",
new KeyboardInteractiveAuthenticationMethod("user"));
_connectionInfo.Timeout = TimeSpan.FromMilliseconds(random.Next(50, 200));
new KeyboardInteractiveAuthenticationMethod("user"))
{
Timeout = TimeSpan.FromMilliseconds(random.Next(50, 200))
};
_stopWatch = new Stopwatch();
_actualException = null;
@@ -54,23 +59,16 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_server != null)
{
_server.Dispose();
}
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
_server?.Dispose();
_proxyServer?.Dispose();
}
protected override void Act()
@@ -79,7 +77,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (SshOperationTimeoutException ex)
@@ -126,7 +124,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_clientSocket.Receive(new byte[0]);
_ = _clientSocket.Receive(new byte[0]);
Assert.Fail();
}
catch (ObjectDisposedException)
@@ -1,8 +1,4 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Renci.SshNet.Common;
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
@@ -10,6 +6,12 @@ using System.Net.Sockets;
using System.Text;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Renci.SshNet.Common;
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -63,7 +65,9 @@ namespace Renci.SshNet.Tests.Classes.Connection
_server.BytesReceived += (bytes, socket) =>
{
_dataReceivedByServer.AddRange(bytes);
socket.Send(_serverIdentification);
_ = socket.Send(_serverIdentification);
socket.Shutdown(SocketShutdown.Send);
};
_server.Disconnected += (socket) => _clientDisconnected = true;
@@ -78,7 +82,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_protocolVersionExchange.Start(_clientVersion, _client, _timeout);
_ = _protocolVersionExchange.Start(_clientVersion, _client, _timeout);
Assert.Fail();
}
catch (SshConnectionException ex)
@@ -1,8 +1,4 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Renci.SshNet.Common;
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
@@ -10,6 +6,12 @@ using System.Net.Sockets;
using System.Text;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Renci.SshNet.Common;
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -61,11 +63,13 @@ namespace Renci.SshNet.Tests.Classes.Connection
_server = new AsyncSocketListener(_serverEndPoint);
_server.Start();
_server.BytesReceived += (bytes, socket) =>
{
_dataReceivedByServer.AddRange(bytes);
socket.Send(_serverIdentification);
socket.Shutdown(SocketShutdown.Send);
};
{
_dataReceivedByServer.AddRange(bytes);
_ = socket.Send(_serverIdentification);
socket.Shutdown(SocketShutdown.Send);
};
_server.Disconnected += (socket) => _clientDisconnected = true;
_client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
@@ -1,8 +1,4 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Renci.SshNet.Common;
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
@@ -10,6 +6,12 @@ using System.Net.Sockets;
using System.Text;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Renci.SshNet.Common;
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -61,7 +63,8 @@ namespace Renci.SshNet.Tests.Classes.Connection
_server.BytesReceived += (bytes, socket) =>
{
_dataReceivedByServer.AddRange(bytes);
socket.Send(Encoding.UTF8.GetBytes("Welcome!\r\n"));
_ = socket.Send(Encoding.UTF8.GetBytes("Welcome!\r\n"));
};
_server.Disconnected += (socket) => _clientDisconnected = true;
@@ -75,7 +78,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_protocolVersionExchange.Start(_clientVersion, _client, _timeout);
_ = _protocolVersionExchange.Start(_clientVersion, _client, _timeout);
Assert.Fail();
}
catch (SshOperationTimeoutException ex)
@@ -1,8 +1,9 @@
using Moq;
using System.Net;
using Moq;
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
using System.Net;
using System.Threading;
namespace Renci.SshNet.Tests.Classes.Connection
{
@@ -1,13 +1,16 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -36,7 +39,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
if (_bytesReceivedByProxy.Count == 0)
{
socket.Send(new byte[]
_ = socket.Send(new byte[]
{
// Reply version (null byte)
0x00,
@@ -52,30 +55,23 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
if (_clientSocket != null)
{
_clientSocket.Dispose();
}
_proxyServer?.Dispose();
_clientSocket?.Dispose();
}
protected override void Act()
{
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (ProxyException ex)
@@ -106,7 +102,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_clientSocket.Receive(new byte[0]);
_ = _clientSocket.Receive(new byte[0]);
Assert.Fail();
}
catch (ObjectDisposedException)
@@ -120,19 +116,5 @@ namespace Renci.SshNet.Tests.Classes.Connection
SocketFactoryMock.Verify(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp),
Times.Once());
}
private static byte GetNotSupportedSocksVersion()
{
var random = new Random();
while (true)
{
var socksVersion = random.Next(1, 255);
if (socksVersion != 4)
{
return (byte) socksVersion;
}
}
}
}
}
@@ -1,15 +1,18 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -43,7 +46,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
if (_bytesReceivedByProxy.Count == bytesReceived.Length)
{
// Send SOCKS response
socket.Send(new byte[]
_ = socket.Send(new byte[]
{
// Reply version (null byte)
0x00,
@@ -60,7 +63,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
});
// Send extra byte to allow us to verify that connector did not consume too much
socket.Send(new byte[]
_ = socket.Send(new byte[]
{
0xfe
});
@@ -71,23 +74,16 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
if (_clientSocket != null)
{
_clientSocket.Dispose();
}
_proxyServer?.Dispose();
_clientSocket?.Dispose();
}
protected override void Act()
@@ -1,10 +1,11 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using System;
using System;
using System.Diagnostics;
using System.Net.Sockets;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -29,18 +30,15 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_clientSocket != null)
{
_clientSocket.Dispose();
}
_clientSocket?.Dispose();
}
protected override void Act()
@@ -49,7 +47,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (SocketException ex)
@@ -85,7 +83,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_clientSocket.Receive(new byte[0]);
_ = _clientSocket.Receive(new byte[0]);
Assert.Fail();
}
catch (ObjectDisposedException)
@@ -31,18 +31,15 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_clientSocket != null)
{
_clientSocket.Dispose();
}
_clientSocket?.Dispose();
}
protected override void Act()
@@ -51,7 +48,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (SshOperationTimeoutException ex)
@@ -88,7 +85,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_clientSocket.Receive(new byte[0]);
_ = _clientSocket.Receive(new byte[0]);
Assert.Fail();
}
catch (ObjectDisposedException)
@@ -1,15 +1,18 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Diagnostics;
using System.Globalization;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -40,7 +43,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
_proxyServer.Disconnected += socket => _disconnected = true;
_proxyServer.Connected += socket =>
{
socket.Send(new byte[]
_ = socket.Send(new byte[]
{
// Reply version (null byte)
0x00,
@@ -58,23 +61,16 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_server != null)
{
_server.Dispose();
}
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
_server?.Dispose();
_proxyServer?.Dispose();
}
protected override void Act()
@@ -83,7 +79,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (SshOperationTimeoutException ex)
@@ -130,7 +126,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_clientSocket.Receive(new byte[0]);
_ = _clientSocket.Receive(new byte[0]);
Assert.Fail();
}
catch (ObjectDisposedException)
@@ -1,15 +1,18 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Diagnostics;
using System.Globalization;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -40,7 +43,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
_proxyServer.Disconnected += socket => _disconnected = true;
_proxyServer.Connected += socket =>
{
socket.Send(new byte[]
_ = socket.Send(new byte[]
{
// Reply version (null byte)
0x00
@@ -54,23 +57,16 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_server != null)
{
_server.Dispose();
}
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
_server?.Dispose();
_proxyServer?.Dispose();
}
protected override void Act()
@@ -79,7 +75,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (SshOperationTimeoutException ex)
@@ -46,23 +46,16 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_server != null)
{
_server.Dispose();
}
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
_server?.Dispose();
_proxyServer?.Dispose();
}
protected override void Act()
@@ -71,7 +64,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (SshOperationTimeoutException ex)
@@ -118,7 +111,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_clientSocket.Receive(new byte[0]);
_ = _clientSocket.Receive(new byte[0]);
Assert.Fail();
}
catch (ObjectDisposedException)
@@ -1,10 +1,11 @@
using Moq;
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
using System;
using System.Net;
using System.Text;
using System.Threading;
namespace Renci.SshNet.Tests.Classes.Connection
{
@@ -59,8 +60,8 @@ namespace Renci.SshNet.Tests.Classes.Connection
for (var i = 0; i < length; i++)
{
var @char = (char) random.Next(offset, offset + 26);
sb.Append(@char);
var c = (char) random.Next(offset, offset + 26);
_ = sb.Append(c);
}
return sb.ToString();
@@ -1,11 +1,11 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using System;
using System;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -30,18 +30,15 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_clientSocket != null)
{
_clientSocket.Dispose();
}
_clientSocket?.Dispose();
}
protected override void Act()
@@ -50,7 +47,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (SocketException ex)
@@ -86,7 +83,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_clientSocket.Receive(new byte[0]);
_ = _clientSocket.Receive(new byte[0]);
Assert.Fail();
}
catch (ObjectDisposedException)
@@ -39,7 +39,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
// We received the greeting
socket.Send(new byte[]
_ = socket.Send(new byte[]
{
// SOCKS version
0x05,
@@ -51,7 +51,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
// We received the connection request
socket.Send(new byte[]
_ = socket.Send(new byte[]
{
// SOCKS version
0x05,
@@ -62,7 +62,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
});
// Send server bound address
socket.Send(new byte[]
_ = socket.Send(new byte[]
{
// IPv6
0x04,
@@ -89,7 +89,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
});
// Send extra byte to allow us to verify that connector did not consume too much
socket.Send(new byte[]
_ = socket.Send(new byte[]
{
0xff
});
@@ -100,18 +100,15 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
_proxyServer?.Dispose();
if (_clientSocket != null)
{
@@ -1,12 +1,15 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -34,37 +37,30 @@ namespace Renci.SshNet.Tests.Classes.Connection
_proxyServer.Disconnected += socket => _disconnected = true;
_proxyServer.BytesReceived += (bytesReceived, socket) =>
{
socket.Send(new byte[] { _proxySocksVersion });
_ = socket.Send(new byte[] { _proxySocksVersion });
};
_proxyServer.Start();
}
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
if (_clientSocket != null)
{
_clientSocket.Dispose();
}
_proxyServer?.Dispose();
_clientSocket?.Dispose();
}
protected override void Act()
{
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (ProxyException ex)
@@ -95,7 +91,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_clientSocket.Receive(new byte[0]);
_ = _clientSocket.Receive(new byte[0]);
Assert.Fail();
}
catch (ObjectDisposedException)
@@ -1,12 +1,14 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using System;
using System;
using System.Diagnostics;
using System.Globalization;
using System.Net;
using System.Net.Sockets;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -33,18 +35,15 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_clientSocket != null)
{
_clientSocket.Dispose();
}
_clientSocket?.Dispose();
}
protected override void Act()
@@ -53,7 +52,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (SshOperationTimeoutException ex)
@@ -90,7 +89,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_clientSocket.Receive(new byte[0]);
_ = _clientSocket.Receive(new byte[0]);
Assert.Fail();
}
catch (ObjectDisposedException)
@@ -42,7 +42,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
// We received the greeting
socket.Send(new byte[]
_ = socket.Send(new byte[]
{
// SOCKS version
0x05,
@@ -54,7 +54,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
// We received the username/password authentication request
socket.Send(new byte[]
_ = socket.Send(new byte[]
{
// Authentication version
0x01,
@@ -68,30 +68,23 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
if (_clientSocket != null)
{
_clientSocket.Dispose();
}
_proxyServer?.Dispose();
_clientSocket?.Dispose();
}
protected override void Act()
{
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (ProxyException ex)
@@ -163,7 +156,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_clientSocket.Receive(new byte[0]);
_ = _clientSocket.Receive(new byte[0]);
Assert.Fail();
}
catch (ObjectDisposedException)
@@ -1,8 +1,4 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
@@ -10,6 +6,13 @@ using System.Net.Sockets;
using System.Text;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -40,7 +43,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
// We received the greeting
socket.Send(new byte[]
_ = socket.Send(new byte[]
{
// SOCKS version
0x05,
@@ -52,7 +55,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
// We received the username/password authentication request
socket.Send(new byte[]
_ = socket.Send(new byte[]
{
// Authentication version
0x01,
@@ -64,7 +67,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
// We received the connection request
socket.Send(new byte[]
_ = socket.Send(new byte[]
{
// SOCKS version
0x05,
@@ -75,7 +78,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
});
// Send server bound address
socket.Send(new byte[]
_ = socket.Send(new byte[]
{
// IPv4
0x01,
@@ -90,7 +93,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
});
// Send extra byte to allow us to verify that connector did not consume too much
socket.Send(new byte[]
_ = socket.Send(new byte[]
{
0xfe
});
@@ -101,18 +104,15 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
_proxyServer?.Dispose();
if (_clientSocket != null)
{
@@ -41,7 +41,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
// Wait until we received the greeting
if (_bytesReceivedByProxy.Count == 4)
{
socket.Send(new byte[]
_ = socket.Send(new byte[]
{
// SOCKS version
0x05,
@@ -55,30 +55,23 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
if (_clientSocket != null)
{
_clientSocket.Dispose();
}
_proxyServer?.Dispose();
_clientSocket?.Dispose();
}
protected override void Act()
{
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (ProxyException ex)
@@ -135,7 +128,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_clientSocket.Receive(new byte[0]);
_ = _clientSocket.Receive(new byte[0]);
Assert.Fail();
}
catch (ObjectDisposedException)
@@ -1,14 +1,17 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Tests.Common;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Common;
using Renci.SshNet.Tests.Common;
namespace Renci.SshNet.Tests.Classes.Connection
{
[TestClass]
@@ -41,7 +44,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
// Wait until we received the greeting
if (_bytesReceivedByProxy.Count == 4)
{
socket.Send(new byte[]
_ = socket.Send(new byte[]
{
// SOCKS version
0x05,
@@ -55,30 +58,23 @@ namespace Renci.SshNet.Tests.Classes.Connection
protected override void SetupMocks()
{
SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
_ = SocketFactoryMock.Setup(p => p.Create(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
.Returns(_clientSocket);
}
protected override void TearDown()
{
base.TearDown();
if (_proxyServer != null)
{
_proxyServer.Dispose();
}
if (_clientSocket != null)
{
_clientSocket.Dispose();
}
_proxyServer?.Dispose();
_clientSocket?.Dispose();
}
protected override void Act()
{
try
{
Connector.Connect(_connectionInfo);
_ = Connector.Connect(_connectionInfo);
Assert.Fail();
}
catch (ProxyException ex)
@@ -101,20 +97,18 @@ namespace Renci.SshNet.Tests.Classes.Connection
[TestMethod]
public void ProxyShouldHaveReceivedExpectedSocksRequest()
{
var expectedSocksRequest = new List<byte>();
//
// Client greeting
//
// SOCKS version
expectedSocksRequest.Add(0x05);
// Number of authentication methods supported
expectedSocksRequest.Add(0x02);
// No authentication
expectedSocksRequest.Add(0x00);
// Username/password
expectedSocksRequest.Add(0x02);
var expectedSocksRequest = new List<byte>
{
// SOCKS version
0x05,
// Number of authentication methods supported
0x02,
// No authentication
0x00,
// Username/password
0x02
};
var errorText = string.Format("Expected:{0}{1}{0}but was:{0}{2}",
Environment.NewLine,
@@ -135,7 +129,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
{
try
{
_clientSocket.Receive(new byte[0]);
_ = _clientSocket.Receive(new byte[0]);
Assert.Fail();
}
catch (ObjectDisposedException)
@@ -27,7 +27,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
try
{
new SshIdentification(protocolVersion, softwareVersion);
_ = new SshIdentification(protocolVersion, softwareVersion);
Assert.Fail();
}
catch (ArgumentNullException ex)
@@ -45,7 +45,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
try
{
new SshIdentification(protocolVersion, softwareVersion);
_ = new SshIdentification(protocolVersion, softwareVersion);
Assert.Fail();
}
catch (ArgumentNullException ex)
@@ -90,7 +90,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
try
{
new SshIdentification(protocolVersion, softwareVersion, comments);
_ = new SshIdentification(protocolVersion, softwareVersion, comments);
Assert.Fail();
}
catch (ArgumentNullException ex)
@@ -109,7 +109,7 @@ namespace Renci.SshNet.Tests.Classes.Connection
try
{
new SshIdentification(protocolVersion, softwareVersion, comments);
_ = new SshIdentification(protocolVersion, softwareVersion, comments);
Assert.Fail();
}
catch (ArgumentNullException ex)
@@ -33,9 +33,15 @@ namespace Renci.SshNet.Tests.Classes
{
try
{
new ConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, ProxyTypes.Http, null,
int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD,
new KeyboardInteractiveAuthenticationMethod(Resources.USERNAME));
_ = new ConnectionInfo(Resources.HOST,
int.Parse(Resources.PORT),
Resources.USERNAME,
ProxyTypes.Http,
null,
int.Parse(Resources.PORT),
Resources.USERNAME,
Resources.PASSWORD,
new KeyboardInteractiveAuthenticationMethod(Resources.USERNAME));
Assert.Fail();
}
catch (ArgumentNullException ex)
@@ -51,8 +57,14 @@ namespace Renci.SshNet.Tests.Classes
{
var proxyHost = string.Empty;
var connectionInfo = new ConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME,
ProxyTypes.Http, string.Empty, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD,
var connectionInfo = new ConnectionInfo(Resources.HOST,
int.Parse(Resources.PORT),
Resources.USERNAME,
ProxyTypes.Http,
string.Empty,
int.Parse(Resources.PORT),
Resources.USERNAME,
Resources.PASSWORD,
new KeyboardInteractiveAuthenticationMethod(Resources.USERNAME));
Assert.AreSame(proxyHost, connectionInfo.ProxyHost);
@@ -66,7 +78,15 @@ namespace Renci.SshNet.Tests.Classes
try
{
new ConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, ProxyTypes.Http, Resources.HOST, ++maxPort, Resources.USERNAME, Resources.PASSWORD, null);
_ = new ConnectionInfo(Resources.HOST,
int.Parse(Resources.PORT),
Resources.USERNAME,
ProxyTypes.Http,
Resources.HOST,
++maxPort,
Resources.USERNAME,
Resources.PASSWORD,
null);
Assert.Fail();
}
catch (ArgumentOutOfRangeException ex)
@@ -84,7 +104,15 @@ namespace Renci.SshNet.Tests.Classes
try
{
new ConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, ProxyTypes.Http, Resources.HOST, --minPort, Resources.USERNAME, Resources.PASSWORD, null);
_ = new ConnectionInfo(Resources.HOST,
int.Parse(Resources.PORT),
Resources.USERNAME,
ProxyTypes.Http,
Resources.HOST,
--minPort,
Resources.USERNAME,
Resources.PASSWORD,
null);
Assert.Fail();
}
catch (ArgumentOutOfRangeException ex)
@@ -126,8 +154,15 @@ namespace Renci.SshNet.Tests.Classes
{
try
{
new ConnectionInfo(null, int.Parse(Resources.PORT), Resources.USERNAME, ProxyTypes.None, Resources.HOST,
int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD, null);
_ = new ConnectionInfo(null,
int.Parse(Resources.PORT),
Resources.USERNAME,
ProxyTypes.None,
Resources.HOST,
int.Parse(Resources.PORT),
Resources.USERNAME,
Resources.PASSWORD,
null);
}
catch (ArgumentNullException ex)
{
@@ -183,8 +218,15 @@ namespace Renci.SshNet.Tests.Classes
try
{
new ConnectionInfo(Resources.HOST, port, Resources.USERNAME, ProxyTypes.None, Resources.HOST,
int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD, null);
_ = new ConnectionInfo(Resources.HOST,
port,
Resources.USERNAME,
ProxyTypes.None,
Resources.HOST,
int.Parse(Resources.PORT),
Resources.USERNAME,
Resources.PASSWORD,
null);
Assert.Fail();
}
catch (ArgumentOutOfRangeException ex)
@@ -202,8 +244,15 @@ namespace Renci.SshNet.Tests.Classes
try
{
new ConnectionInfo(Resources.HOST, port, Resources.USERNAME, ProxyTypes.None, Resources.HOST,
int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD, null);
_ = new ConnectionInfo(Resources.HOST,
port,
Resources.USERNAME,
ProxyTypes.None,
Resources.HOST,
int.Parse(Resources.PORT),
Resources.USERNAME,
Resources.PASSWORD,
null);
Assert.Fail();
}
catch (ArgumentOutOfRangeException ex)
@@ -234,9 +283,15 @@ namespace Renci.SshNet.Tests.Classes
try
{
new ConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), username, ProxyTypes.Http, Resources.USERNAME,
int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD,
new KeyboardInteractiveAuthenticationMethod(Resources.USERNAME));
_ = new ConnectionInfo(Resources.HOST,
int.Parse(Resources.PORT),
username,
ProxyTypes.Http,
Resources.USERNAME,
int.Parse(Resources.PORT),
Resources.USERNAME,
Resources.PASSWORD,
new KeyboardInteractiveAuthenticationMethod(Resources.USERNAME));
Assert.Fail();
}
catch (ArgumentNullException ex)
@@ -254,9 +309,15 @@ namespace Renci.SshNet.Tests.Classes
try
{
new ConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), username, ProxyTypes.Http, Resources.USERNAME,
int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD,
new KeyboardInteractiveAuthenticationMethod(Resources.USERNAME));
_ = new ConnectionInfo(Resources.HOST,
int.Parse(Resources.PORT),
username,
ProxyTypes.Http,
Resources.USERNAME,
int.Parse(Resources.PORT),
Resources.USERNAME,
Resources.PASSWORD,
new KeyboardInteractiveAuthenticationMethod(Resources.USERNAME));
Assert.Fail();
}
catch (ArgumentException ex)
@@ -275,9 +336,15 @@ namespace Renci.SshNet.Tests.Classes
try
{
new ConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), username, ProxyTypes.Http, Resources.USERNAME,
int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD,
new KeyboardInteractiveAuthenticationMethod(Resources.USERNAME));
_ = new ConnectionInfo(Resources.HOST,
int.Parse(Resources.PORT),
username,
ProxyTypes.Http,
Resources.USERNAME,
int.Parse(Resources.PORT),
Resources.USERNAME,
Resources.PASSWORD,
new KeyboardInteractiveAuthenticationMethod(Resources.USERNAME));
Assert.Fail();
}
catch (ArgumentException ex)
@@ -294,8 +361,15 @@ namespace Renci.SshNet.Tests.Classes
{
try
{
new ConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, ProxyTypes.None, Resources.HOST,
int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD, null);
_ = new ConnectionInfo(Resources.HOST,
int.Parse(Resources.PORT),
Resources.USERNAME,
ProxyTypes.None,
Resources.HOST,
int.Parse(Resources.PORT),
Resources.USERNAME,
Resources.PASSWORD,
null);
Assert.Fail();
}
catch (ArgumentNullException ex)
@@ -311,8 +385,15 @@ namespace Renci.SshNet.Tests.Classes
{
try
{
new ConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, ProxyTypes.None, Resources.HOST,
int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD, new AuthenticationMethod[0]);
_ = new ConnectionInfo(Resources.HOST,
int.Parse(Resources.PORT),
Resources.USERNAME,
ProxyTypes.None,
Resources.HOST,
int.Parse(Resources.PORT),
Resources.USERNAME,
Resources.PASSWORD,
new AuthenticationMethod[0]);
Assert.Fail();
}
catch (ArgumentException ex)
@@ -326,11 +407,18 @@ namespace Renci.SshNet.Tests.Classes
[TestCategory("ConnectionInfo")]
public void AuthenticateShouldThrowArgumentNullExceptionWhenServiceFactoryIsNull()
{
var connectionInfo = new ConnectionInfo(Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, ProxyTypes.None,
Resources.HOST, int.Parse(Resources.PORT), Resources.USERNAME, Resources.PASSWORD,
new KeyboardInteractiveAuthenticationMethod(Resources.USERNAME));
var connectionInfo = new ConnectionInfo(Resources.HOST,
int.Parse(Resources.PORT),
Resources.USERNAME,
ProxyTypes.None,
Resources.HOST,
int.Parse(Resources.PORT),
Resources.USERNAME,
Resources.PASSWORD,
new KeyboardInteractiveAuthenticationMethod(Resources.USERNAME));
var session = new Mock<ISession>(MockBehavior.Strict).Object;
IServiceFactory serviceFactory = null;
const IServiceFactory serviceFactory = null;
try
{
@@ -344,4 +432,4 @@ namespace Renci.SshNet.Tests.Classes
}
}
}
}
}
@@ -2,9 +2,11 @@
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Renci.SshNet.Channels;
using Renci.SshNet.Common;
namespace Renci.SshNet.Tests.Classes

Some files were not shown because too many files have changed in this diff Show More