Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ public void KeyboardInteractive_NoResponseSet_ThrowsSshAuthenticationException()
catch (SshAuthenticationException ex)
{
Assert.IsNull(ex.InnerException);
Assert.IsTrue(ex.Message.StartsWith("AuthenticationPrompt.Response is null for prompt \"Password: \""), $"Message was \"{ex.Message}\"");
Assert.StartsWith("AuthenticationPrompt.Response is null for prompt \"Password: \"", ex.Message, $"Message was \"{ex.Message}\"");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/Renci.SshNet.IntegrationTests/ConnectivityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public void Common_HostKeyAlgorithms_NoMatch()
var ex = Assert.Throws<SshConnectionException>(client.Connect);

Assert.AreEqual(DisconnectReason.KeyExchangeFailed, ex.DisconnectReason);
Assert.IsTrue(ex.Message.StartsWith("No matching host key algorithm"), ex.Message);
Assert.StartsWith("No matching host key algorithm", ex.Message, ex.Message);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void Test_Sftp_ListDirectory_Current()

var files = sftp.ListDirectory(".");

Assert.IsTrue(files.Count() > 0);
Assert.IsGreaterThan(0, files.Count());

foreach (var file in files)
{
Expand Down Expand Up @@ -71,7 +71,7 @@ public async Task Test_Sftp_ListDirectoryAsync_Current()
Debug.WriteLine(file.FullName);
}

Assert.IsTrue(count > 0);
Assert.IsGreaterThan(0, count);

sftp.Disconnect();
}
Expand All @@ -87,7 +87,7 @@ public void Test_Sftp_ListDirectory_Empty()

var files = sftp.ListDirectory(string.Empty);

Assert.IsTrue(files.Count() > 0);
Assert.IsGreaterThan(0, files.Count());

foreach (var file in files)
{
Expand Down Expand Up @@ -128,7 +128,7 @@ public void Test_Sftp_ListDirectory_HugeDirectory()
var files = sftp.ListDirectory(".");

// Ensure that directory has at least 10000 items
Assert.IsTrue(files.Count() > 10000);
Assert.IsGreaterThan(10000, files.Count());

sftp.Disconnect();
}
Expand Down Expand Up @@ -158,7 +158,7 @@ public void Test_Sftp_Change_Directory()

var files = sftp.ListDirectory(".");

Assert.IsTrue(files.First().FullName.StartsWith(string.Format("{0}", sftp.WorkingDirectory)));
Assert.StartsWith(string.Format("{0}", sftp.WorkingDirectory), files.First().FullName);

sftp.ChangeDirectory("test1_1");

Expand All @@ -178,7 +178,7 @@ public void Test_Sftp_Change_Directory()

files = sftp.ListDirectory("test1/test1_1");

Assert.IsTrue(files.First().FullName.StartsWith(string.Format("{0}/test1/test1_1", sftp.WorkingDirectory)));
Assert.StartsWith(string.Format("{0}/test1/test1_1", sftp.WorkingDirectory), files.First().FullName);

sftp.ChangeDirectory("test1/test1_1");

Expand Down Expand Up @@ -227,7 +227,7 @@ public async Task Test_Sftp_Change_DirectoryAsync()

var files = sftp.ListDirectory(".");

Assert.IsTrue(files.First().FullName.StartsWith(string.Format("{0}", sftp.WorkingDirectory)));
Assert.StartsWith(string.Format("{0}", sftp.WorkingDirectory), files.First().FullName);

await sftp.ChangeDirectoryAsync("test1_1", CancellationToken.None).ConfigureAwait(false);

Expand All @@ -247,7 +247,7 @@ public async Task Test_Sftp_Change_DirectoryAsync()

files = sftp.ListDirectory("test1/test1_1");

Assert.IsTrue(files.First().FullName.StartsWith(string.Format("{0}/test1/test1_1", sftp.WorkingDirectory)));
Assert.StartsWith(string.Format("{0}/test1/test1_1", sftp.WorkingDirectory), files.First().FullName);

await sftp.ChangeDirectoryAsync("test1/test1_1", CancellationToken.None).ConfigureAwait(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void Test_Sftp_SynchronizeDirectories()
string searchPattern = Path.GetFileName(uploadedFileName);
var upLoadedFiles = sftp.SynchronizeDirectories(sourceDir, destDir, searchPattern);

Assert.IsTrue(upLoadedFiles.Count() > 0);
Assert.IsGreaterThan(0, upLoadedFiles.Count());

foreach (var file in upLoadedFiles)
{
Expand Down Expand Up @@ -63,7 +63,7 @@ public void Test_Sftp_BeginSynchronizeDirectories()

var upLoadedFiles = sftp.EndSynchronizeDirectories(asyncResult);

Assert.IsTrue(upLoadedFiles.Count() > 0);
Assert.IsGreaterThan(0, upLoadedFiles.Count());

foreach (var file in upLoadedFiles)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public void Test_Execute_InvalidCommand()
{
Assert.Fail("Operation should fail");
}
Assert.IsTrue(cmd.ExitStatus > 0);
Assert.IsGreaterThan(0, cmd.ExitStatus.Value);

client.Disconnect();
}
Expand All @@ -244,7 +244,7 @@ public void Test_Execute_InvalidCommand_Then_Execute_ValidCommand()
{
Assert.Fail("Operation should fail");
}
Assert.IsTrue(cmd.ExitStatus > 0);
Assert.IsGreaterThan(0, cmd.ExitStatus.Value);

var result = ExecuteTestCommand(client);

Expand Down
8 changes: 4 additions & 4 deletions test/Renci.SshNet.IntegrationTests/ScpTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,19 +380,19 @@ public void Scp_Download_DirectoryInfo_ExistingDirectory(IRemotePathTransformati
}

var localFiles = Directory.GetFiles(localDirectory);
Assert.AreEqual(2, localFiles.Length);
Assert.HasCount(2, localFiles);
Assert.IsTrue(localFiles.Contains(localPathFile1));
Assert.IsTrue(localFiles.Contains(localPathFile2));

var localSubDirecties = Directory.GetDirectories(localDirectory);
Assert.AreEqual(1, localSubDirecties.Length);
Assert.HasCount(1, localSubDirecties);
Assert.AreEqual(localPathSubDirectory, localSubDirecties[0]);

var localFilesSubDirectory = Directory.GetFiles(localPathSubDirectory);
Assert.AreEqual(1, localFilesSubDirectory.Length);
Assert.HasCount(1, localFilesSubDirectory);
Assert.AreEqual(localPathFile3, localFilesSubDirectory[0]);

Assert.AreEqual(0, Directory.GetDirectories(localPathSubDirectory).Length);
Assert.IsEmpty(Directory.GetDirectories(localPathSubDirectory));
}
finally
{
Expand Down
2 changes: 1 addition & 1 deletion test/Renci.SshNet.IntegrationTests/SftpTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3669,7 +3669,7 @@ public void Sftp_ListDirectory()
client.ChangeDirectory(remoteDirectory);

var directoryContent = client.ListDirectory(".").OrderBy(p => p.Name).ToList();
Assert.AreEqual(5, directoryContent.Count);
Assert.HasCount(5, directoryContent);

Assert.AreEqual(".", directoryContent[0].Name);
Assert.AreEqual($"{remoteDirectory}/.", directoryContent[0].FullName);
Expand Down
16 changes: 8 additions & 8 deletions test/Renci.SshNet.IntegrationTests/SshTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void Ssh_ShellStream_Exit()

var line = shellStream.ReadLine();
Assert.IsNotNull(line);
Assert.IsTrue(line.EndsWith("Hello!"), line);
Assert.EndsWith("Hello!", line, line);

Assert.IsTrue(shellStream.ReadLine() is null || shellStream.ReadLine() is null); // we might first get e.g. "renci-ssh-tests-server:~$"
}
Expand All @@ -94,7 +94,7 @@ public void Ssh_CreateShellStreamNoTerminal()
shellStream.WriteLine($"echo {foo}");
var line = shellStream.ReadLine(TimeSpan.FromSeconds(1));
Assert.IsNotNull(line);
Assert.IsTrue(line.EndsWith(foo), line);
Assert.EndsWith(foo, line, line);
}
}
}
Expand Down Expand Up @@ -221,7 +221,7 @@ public void Ssh_CreateShellNoTerminal()
var outputString = outputReader.ReadLine();

Assert.IsNotNull(outputString);
Assert.IsTrue(outputString.EndsWith(foo), outputString);
Assert.EndsWith(foo, outputString, outputString);

shell.Stop();
}
Expand Down Expand Up @@ -341,7 +341,7 @@ public async Task Ssh_Command_IntermittentOutput_OutputStream()
lines.Add(line);
}

Assert.AreEqual(6, lines.Count, string.Join("\n", lines));
Assert.HasCount(6, lines, string.Join("\n", lines));
Assert.AreEqual(expectedResult, string.Join("\n", lines));
}

Expand Down Expand Up @@ -383,7 +383,7 @@ public void Ssh_DynamicPortForwarding_DisposeSshClientWithoutStoppingPort()
socksSocket.Send(httpGetRequest);

var httpResponse = GetHttpResponse(socksSocket, Encoding.ASCII);
Assert.IsTrue(httpResponse.Contains(searchText), httpResponse);
Assert.Contains(searchText, httpResponse, httpResponse);
}

Assert.IsTrue(socksSocket.Connected);
Expand Down Expand Up @@ -427,7 +427,7 @@ public void Ssh_DynamicPortForwarding_DomainName()

socksSocket.Send(httpGetRequest);
var httpResponse = GetHttpResponse(socksSocket, Encoding.ASCII);
Assert.IsTrue(httpResponse.Contains(searchText), httpResponse);
Assert.Contains(searchText, httpResponse, httpResponse);

// Verify if port is still open
socksSocket.Send(httpGetRequest);
Expand All @@ -447,7 +447,7 @@ public void Ssh_DynamicPortForwarding_DomainName()

socksSocket.Send(httpGetRequest);
httpResponse = GetHttpResponse(socksSocket, Encoding.ASCII);
Assert.IsTrue(httpResponse.Contains(searchText), httpResponse);
Assert.Contains(searchText, httpResponse, httpResponse);

forwardedPort.Dispose();

Expand Down Expand Up @@ -496,7 +496,7 @@ public void Ssh_DynamicPortForwarding_IPv4()

socksSocket.Send(httpGetRequest);
var httpResponse = GetHttpResponse(socksSocket, Encoding.ASCII);
Assert.IsTrue(httpResponse.Contains(searchText), httpResponse);
Assert.Contains(searchText, httpResponse, httpResponse);

forwardedPort.Dispose();

Expand Down
4 changes: 2 additions & 2 deletions test/Renci.SshNet.IntegrationTests/SshTests_TTYDisabled.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void Ssh_CreateShellStreamNoTerminal()
shellStream.WriteLine($"echo {foo}");
var line = shellStream.ReadLine(TimeSpan.FromSeconds(1));
Assert.IsNotNull(line);
Assert.IsTrue(line.EndsWith(foo), line);
Assert.EndsWith(foo, line, line);
}
}
}
Expand Down Expand Up @@ -122,7 +122,7 @@ public void Ssh_CreateShellNoTerminal()
var outputString = outputReader.ReadLine();

Assert.IsNotNull(outputString);
Assert.IsTrue(outputString.EndsWith(foo), outputString);
Assert.EndsWith(foo, outputString, outputString);

shell.Stop();
}
Expand Down
6 changes: 3 additions & 3 deletions test/Renci.SshNet.Tests/Classes/AbstractionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class AbstractionsTest
[TestMethod]
public void CryptoAbstraction_GenerateRandom_ShouldPerformNoOpWhenDataIsZeroLength()
{
Assert.AreEqual(0, CryptoAbstraction.GenerateRandom(0).Length);
Assert.IsEmpty(CryptoAbstraction.GenerateRandom(0));
}

[TestMethod]
Expand All @@ -22,8 +22,8 @@ public void CryptoAbstraction_GenerateRandom_ShouldGenerateRandomSequenceOfValue
var dataA = CryptoAbstraction.GenerateRandom(dataLength);
var dataB = CryptoAbstraction.GenerateRandom(dataLength);

Assert.AreEqual(dataLength, dataA.Length);
Assert.AreEqual(dataLength, dataB.Length);
Assert.HasCount(dataLength, dataA);
Assert.HasCount(dataLength, dataB);

CollectionAssert.AreNotEqual(dataA, dataB);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ private void Act()
[TestMethod]
public void ChannelShouldShutdownSocketToRemoteListener()
{
Assert.AreEqual(1, _connectedRegister.Count);
Assert.AreEqual(1, _disconnectedRegister.Count);
Assert.HasCount(1, _connectedRegister);
Assert.HasCount(1, _disconnectedRegister);
Assert.AreSame(_connectedRegister[0], _disconnectedRegister[0]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ public void ChannelCloseMessageShouldBeSentOnce()
[TestMethod]
public void ExceptionShouldNeverHaveFired()
{
Assert.AreEqual(0, _channelExceptionRegister.Count);
Assert.IsEmpty(_channelExceptionRegister);
}

[TestMethod]
public void ClosedEventShouldHaveFiredOnce()
{
Assert.AreEqual(1, _channelClosedRegister.Count);
Assert.HasCount(1, _channelClosedRegister);
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
[TestMethod]
public void ExceptionShouldNeverHaveFired()
{
Assert.AreEqual(0, _channelExceptionRegister.Count, _channelExceptionRegister.AsString());
Assert.IsEmpty(_channelExceptionRegister, _channelExceptionRegister.AsString());
}

[TestMethod]
public void ClosedEventShouldHaveFiredOnce()
{
Assert.AreEqual(1, _channelClosedRegister.Count);
Assert.HasCount(1, _channelClosedRegister);
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
[TestMethod]
public void ExceptionShouldNeverHaveFired()
{
Assert.AreEqual(0, _channelExceptionRegister.Count);
Assert.IsEmpty(_channelExceptionRegister);
}

[TestMethod]
public void ClosedEventShouldHaveFiredOnce()
{
Assert.AreEqual(1, _channelClosedRegister.Count);
Assert.HasCount(1, _channelClosedRegister);
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
[TestMethod]
public void ExceptionShouldNeverHaveFired()
{
Assert.AreEqual(0, _channelExceptionRegister.Count, _channelExceptionRegister.AsString());
Assert.IsEmpty(_channelExceptionRegister, _channelExceptionRegister.AsString());
}

[TestMethod]
public void ClosedEventShouldHaveFiredOnce()
{
Assert.AreEqual(1, _channelClosedRegister.Count);
Assert.HasCount(1, _channelClosedRegister);
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
[TestMethod]
public void ExceptionShouldNeverHaveFired()
{
Assert.AreEqual(0, _channelExceptionRegister.Count);
Assert.IsEmpty(_channelExceptionRegister);
}

[TestMethod]
public void ClosedEventShouldHaveFiredOnce()
{
Assert.AreEqual(1, _channelClosedRegister.Count);
Assert.HasCount(1, _channelClosedRegister);
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
[TestMethod]
public void ExceptionShouldNeverHaveFired()
{
Assert.AreEqual(0, _channelExceptionRegister.Count, _channelExceptionRegister.AsString());
Assert.IsEmpty(_channelExceptionRegister, _channelExceptionRegister.AsString());
}

[TestMethod]
public void ClosedEventShouldHaveFiredOnce()
{
Assert.AreEqual(1, _channelClosedRegister.Count);
Assert.HasCount(1, _channelClosedRegister);
Assert.AreEqual(_localChannelNumber, _channelClosedRegister[0].ChannelNumber);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ public void CurrentCountOfSessionSemaphoreShouldBeEqualToInitialCount()
[TestMethod]
public void ExceptionShouldNeverHaveFired()
{
Assert.AreEqual(0, _channelExceptionRegister.Count);
Assert.IsEmpty(_channelExceptionRegister);
}

[TestMethod]
public void ClosedEventShouldNeverHaveFired()
{
Assert.AreEqual(0, _channelClosedRegister.Count);
Assert.IsEmpty(_channelClosedRegister);
}

[TestMethod]
Expand Down
Loading