Skip to content

Commit dd57cf8

Browse files
committed
1 parent b0b2836 commit dd57cf8

File tree

210 files changed

+511
-511
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

210 files changed

+511
-511
lines changed

test/Renci.SshNet.IntegrationTests/AuthenticationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ public void KeyboardInteractive_NoResponseSet_ThrowsSshAuthenticationException()
436436
catch (SshAuthenticationException ex)
437437
{
438438
Assert.IsNull(ex.InnerException);
439-
Assert.IsTrue(ex.Message.StartsWith("AuthenticationPrompt.Response is null for prompt \"Password: \""), $"Message was \"{ex.Message}\"");
439+
Assert.StartsWith("AuthenticationPrompt.Response is null for prompt \"Password: \"", ex.Message, $"Message was \"{ex.Message}\"");
440440
}
441441
}
442442
}

test/Renci.SshNet.IntegrationTests/ConnectivityTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ public void Common_HostKeyAlgorithms_NoMatch()
432432
var ex = Assert.Throws<SshConnectionException>(client.Connect);
433433

434434
Assert.AreEqual(DisconnectReason.KeyExchangeFailed, ex.DisconnectReason);
435-
Assert.IsTrue(ex.Message.StartsWith("No matching host key algorithm"), ex.Message);
435+
Assert.StartsWith("No matching host key algorithm", ex.Message, ex.Message);
436436
}
437437
}
438438

test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ListDirectory.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void Test_Sftp_ListDirectory_Current()
4343

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

46-
Assert.IsTrue(files.Count() > 0);
46+
Assert.IsGreaterThan(0, files.Count());
4747

4848
foreach (var file in files)
4949
{
@@ -71,7 +71,7 @@ public async Task Test_Sftp_ListDirectoryAsync_Current()
7171
Debug.WriteLine(file.FullName);
7272
}
7373

74-
Assert.IsTrue(count > 0);
74+
Assert.IsGreaterThan(0, count);
7575

7676
sftp.Disconnect();
7777
}
@@ -87,7 +87,7 @@ public void Test_Sftp_ListDirectory_Empty()
8787

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

90-
Assert.IsTrue(files.Count() > 0);
90+
Assert.IsGreaterThan(0, files.Count());
9191

9292
foreach (var file in files)
9393
{
@@ -128,7 +128,7 @@ public void Test_Sftp_ListDirectory_HugeDirectory()
128128
var files = sftp.ListDirectory(".");
129129

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

133133
sftp.Disconnect();
134134
}
@@ -158,7 +158,7 @@ public void Test_Sftp_Change_Directory()
158158

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

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

163163
sftp.ChangeDirectory("test1_1");
164164

@@ -178,7 +178,7 @@ public void Test_Sftp_Change_Directory()
178178

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

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

183183
sftp.ChangeDirectory("test1/test1_1");
184184

@@ -227,7 +227,7 @@ public async Task Test_Sftp_Change_DirectoryAsync()
227227

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

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

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

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

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

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

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

test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.SynchronizeDirectories.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public void Test_Sftp_SynchronizeDirectories()
2424
string searchPattern = Path.GetFileName(uploadedFileName);
2525
var upLoadedFiles = sftp.SynchronizeDirectories(sourceDir, destDir, searchPattern);
2626

27-
Assert.IsTrue(upLoadedFiles.Count() > 0);
27+
Assert.IsGreaterThan(0, upLoadedFiles.Count());
2828

2929
foreach (var file in upLoadedFiles)
3030
{
@@ -63,7 +63,7 @@ public void Test_Sftp_BeginSynchronizeDirectories()
6363

6464
var upLoadedFiles = sftp.EndSynchronizeDirectories(asyncResult);
6565

66-
Assert.IsTrue(upLoadedFiles.Count() > 0);
66+
Assert.IsGreaterThan(0, upLoadedFiles.Count());
6767

6868
foreach (var file in upLoadedFiles)
6969
{

test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SshCommandTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public void Test_Execute_InvalidCommand()
226226
{
227227
Assert.Fail("Operation should fail");
228228
}
229-
Assert.IsTrue(cmd.ExitStatus > 0);
229+
Assert.IsGreaterThan(0, cmd.ExitStatus.Value);
230230

231231
client.Disconnect();
232232
}
@@ -244,7 +244,7 @@ public void Test_Execute_InvalidCommand_Then_Execute_ValidCommand()
244244
{
245245
Assert.Fail("Operation should fail");
246246
}
247-
Assert.IsTrue(cmd.ExitStatus > 0);
247+
Assert.IsGreaterThan(0, cmd.ExitStatus.Value);
248248

249249
var result = ExecuteTestCommand(client);
250250

test/Renci.SshNet.IntegrationTests/ScpTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,19 +380,19 @@ public void Scp_Download_DirectoryInfo_ExistingDirectory(IRemotePathTransformati
380380
}
381381

382382
var localFiles = Directory.GetFiles(localDirectory);
383-
Assert.AreEqual(2, localFiles.Length);
383+
Assert.HasCount(2, localFiles);
384384
Assert.IsTrue(localFiles.Contains(localPathFile1));
385385
Assert.IsTrue(localFiles.Contains(localPathFile2));
386386

387387
var localSubDirecties = Directory.GetDirectories(localDirectory);
388-
Assert.AreEqual(1, localSubDirecties.Length);
388+
Assert.HasCount(1, localSubDirecties);
389389
Assert.AreEqual(localPathSubDirectory, localSubDirecties[0]);
390390

391391
var localFilesSubDirectory = Directory.GetFiles(localPathSubDirectory);
392-
Assert.AreEqual(1, localFilesSubDirectory.Length);
392+
Assert.HasCount(1, localFilesSubDirectory);
393393
Assert.AreEqual(localPathFile3, localFilesSubDirectory[0]);
394394

395-
Assert.AreEqual(0, Directory.GetDirectories(localPathSubDirectory).Length);
395+
Assert.IsEmpty(Directory.GetDirectories(localPathSubDirectory));
396396
}
397397
finally
398398
{

test/Renci.SshNet.IntegrationTests/SftpTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3669,7 +3669,7 @@ public void Sftp_ListDirectory()
36693669
client.ChangeDirectory(remoteDirectory);
36703670

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

36743674
Assert.AreEqual(".", directoryContent[0].Name);
36753675
Assert.AreEqual($"{remoteDirectory}/.", directoryContent[0].FullName);

test/Renci.SshNet.IntegrationTests/SshTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void Ssh_ShellStream_Exit()
7474

7575
var line = shellStream.ReadLine();
7676
Assert.IsNotNull(line);
77-
Assert.IsTrue(line.EndsWith("Hello!"), line);
77+
Assert.EndsWith("Hello!", line, line);
7878

7979
Assert.IsTrue(shellStream.ReadLine() is null || shellStream.ReadLine() is null); // we might first get e.g. "renci-ssh-tests-server:~$"
8080
}
@@ -94,7 +94,7 @@ public void Ssh_CreateShellStreamNoTerminal()
9494
shellStream.WriteLine($"echo {foo}");
9595
var line = shellStream.ReadLine(TimeSpan.FromSeconds(1));
9696
Assert.IsNotNull(line);
97-
Assert.IsTrue(line.EndsWith(foo), line);
97+
Assert.EndsWith(foo, line, line);
9898
}
9999
}
100100
}
@@ -221,7 +221,7 @@ public void Ssh_CreateShellNoTerminal()
221221
var outputString = outputReader.ReadLine();
222222

223223
Assert.IsNotNull(outputString);
224-
Assert.IsTrue(outputString.EndsWith(foo), outputString);
224+
Assert.EndsWith(foo, outputString, outputString);
225225

226226
shell.Stop();
227227
}
@@ -341,7 +341,7 @@ public async Task Ssh_Command_IntermittentOutput_OutputStream()
341341
lines.Add(line);
342342
}
343343

344-
Assert.AreEqual(6, lines.Count, string.Join("\n", lines));
344+
Assert.HasCount(6, lines, string.Join("\n", lines));
345345
Assert.AreEqual(expectedResult, string.Join("\n", lines));
346346
}
347347

@@ -383,7 +383,7 @@ public void Ssh_DynamicPortForwarding_DisposeSshClientWithoutStoppingPort()
383383
socksSocket.Send(httpGetRequest);
384384

385385
var httpResponse = GetHttpResponse(socksSocket, Encoding.ASCII);
386-
Assert.IsTrue(httpResponse.Contains(searchText), httpResponse);
386+
Assert.Contains(searchText, httpResponse, httpResponse);
387387
}
388388

389389
Assert.IsTrue(socksSocket.Connected);
@@ -427,7 +427,7 @@ public void Ssh_DynamicPortForwarding_DomainName()
427427

428428
socksSocket.Send(httpGetRequest);
429429
var httpResponse = GetHttpResponse(socksSocket, Encoding.ASCII);
430-
Assert.IsTrue(httpResponse.Contains(searchText), httpResponse);
430+
Assert.Contains(searchText, httpResponse, httpResponse);
431431

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

448448
socksSocket.Send(httpGetRequest);
449449
httpResponse = GetHttpResponse(socksSocket, Encoding.ASCII);
450-
Assert.IsTrue(httpResponse.Contains(searchText), httpResponse);
450+
Assert.Contains(searchText, httpResponse, httpResponse);
451451

452452
forwardedPort.Dispose();
453453

@@ -496,7 +496,7 @@ public void Ssh_DynamicPortForwarding_IPv4()
496496

497497
socksSocket.Send(httpGetRequest);
498498
var httpResponse = GetHttpResponse(socksSocket, Encoding.ASCII);
499-
Assert.IsTrue(httpResponse.Contains(searchText), httpResponse);
499+
Assert.Contains(searchText, httpResponse, httpResponse);
500500

501501
forwardedPort.Dispose();
502502

test/Renci.SshNet.IntegrationTests/SshTests_TTYDisabled.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void Ssh_CreateShellStreamNoTerminal()
6262
shellStream.WriteLine($"echo {foo}");
6363
var line = shellStream.ReadLine(TimeSpan.FromSeconds(1));
6464
Assert.IsNotNull(line);
65-
Assert.IsTrue(line.EndsWith(foo), line);
65+
Assert.EndsWith(foo, line, line);
6666
}
6767
}
6868
}
@@ -122,7 +122,7 @@ public void Ssh_CreateShellNoTerminal()
122122
var outputString = outputReader.ReadLine();
123123

124124
Assert.IsNotNull(outputString);
125-
Assert.IsTrue(outputString.EndsWith(foo), outputString);
125+
Assert.EndsWith(foo, outputString, outputString);
126126

127127
shell.Stop();
128128
}

test/Renci.SshNet.Tests/Classes/AbstractionsTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class AbstractionsTest
1111
[TestMethod]
1212
public void CryptoAbstraction_GenerateRandom_ShouldPerformNoOpWhenDataIsZeroLength()
1313
{
14-
Assert.AreEqual(0, CryptoAbstraction.GenerateRandom(0).Length);
14+
Assert.IsEmpty(CryptoAbstraction.GenerateRandom(0));
1515
}
1616

1717
[TestMethod]
@@ -22,8 +22,8 @@ public void CryptoAbstraction_GenerateRandom_ShouldGenerateRandomSequenceOfValue
2222
var dataA = CryptoAbstraction.GenerateRandom(dataLength);
2323
var dataB = CryptoAbstraction.GenerateRandom(dataLength);
2424

25-
Assert.AreEqual(dataLength, dataA.Length);
26-
Assert.AreEqual(dataLength, dataB.Length);
25+
Assert.HasCount(dataLength, dataA);
26+
Assert.HasCount(dataLength, dataB);
2727

2828
CollectionAssert.AreNotEqual(dataA, dataB);
2929
}

0 commit comments

Comments
 (0)