From f28acf6d6943adb10daac4f2b0701a2f97c1a90b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Aug 2025 20:36:49 +0000 Subject: [PATCH 1/2] Bump the dependencies group with 4 updates Bumps BouncyCastle.Cryptography from 2.6.1 to 2.6.2 Bumps Meziantou.Analyzer from 2.0.205 to 2.0.210 Bumps MSTest from 3.9.3 to 3.10.0 Bumps SonarAnalyzer.CSharp from 10.13.0.120203 to 10.15.0.120848 --- updated-dependencies: - dependency-name: BouncyCastle.Cryptography dependency-version: 2.6.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dependencies - dependency-name: Meziantou.Analyzer dependency-version: 2.0.210 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dependencies - dependency-name: MSTest dependency-version: 3.10.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: dependencies - dependency-name: SonarAnalyzer.CSharp dependency-version: 10.15.0.120848 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: dependencies ... Signed-off-by: dependabot[bot] --- Directory.Packages.props | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 169d98d16..6ae4272d0 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,19 +5,19 @@ - + - + - + - + From 6b7ec2dc7e689cbd818a9388bc9440827412083c Mon Sep 17 00:00:00 2001 From: Rob Hague Date: Sat, 2 Aug 2025 12:54:10 +0200 Subject: [PATCH 2/2] mstest analyzers fixall --- .../ForwardedPortLocalTest.cs | 2 +- .../SftpClientTest.ChangeDirectory.cs | 16 +-- .../SftpClientTest.CreateDirectory.cs | 6 +- .../SftpClientTest.DeleteDirectory.cs | 6 +- .../SftpClientTest.Download.cs | 18 +-- .../SftpClientTest.GetAttributes.cs | 4 +- .../SftpClientTest.GetAttributesAsync.cs | 4 +- .../SftpClientTest.ListDirectory.cs | 12 +- .../SftpClientTest.RenameFile.cs | 2 +- .../SftpClientTest.RenameFileAsync.cs | 2 +- .../SftpClientTest.Upload.cs | 10 +- .../OldIntegrationTests/SftpFileTest.cs | 8 +- .../OldIntegrationTests/SshCommandTest.cs | 16 +-- .../Renci.SshNet.IntegrationTests/ScpTests.cs | 44 +++--- .../SftpClientTests.cs | 2 +- .../SftpTests.cs | 2 +- .../SshClientTests.cs | 4 +- .../Classes/AbstractionsTest.cs | 2 +- .../BaseClientTest_ConnectAsync_Timeout.cs | 4 +- .../Classes/Common/TimeSpanExtensionsTest.cs | 8 +- ...oardInteractiveAuthenticationMethodTest.cs | 4 +- .../Classes/NoneAuthenticationMethodTest.cs | 4 +- .../Classes/OrderedDictionaryTest.cs | 128 +++++++++--------- .../PasswordAuthenticationMethodTest.cs | 6 +- .../Classes/PasswordConnectionInfoTest.cs | 10 +- .../PrivateKeyAuthenticationMethodTest.cs | 6 +- .../Classes/PrivateKeyFileTest.cs | 6 +- .../Security/CertificateHostAlgorithmTest.cs | 2 +- ...setSequenceNumberAfterNewKeys_StrictKex.cs | 2 +- ...SendsDebugMessageAfterKexInit_StrictKex.cs | 2 +- ...DisconnectMessageAfterKexInit_StrictKex.cs | 2 +- ...endsIgnoreMessageAfterKexInit_StrictKex.cs | 2 +- ...ndsIgnoreMessageBeforeKexInit_StrictKex.cs | 2 +- .../Classes/SftpClientTest.DeleteDirectory.cs | 2 +- .../Classes/SftpClientTest.DeleteFile.cs | 2 +- .../Classes/SftpClientTest.DeleteFileAsync.cs | 2 +- .../Classes/SftpClientTest.GetAttributes.cs | 4 +- .../SftpClientTest.GetAttributesAsync.cs | 4 +- .../Classes/SftpClientTest.ListDirectory.cs | 2 +- .../SftpClientTest.ListDirectoryAsync.cs | 2 +- .../Classes/SftpClientTest_AsyncExceptions.cs | 10 +- .../Classes/ShellStreamTest.cs | 4 +- .../Classes/ShellStreamTest_ReadExpect.cs | 4 +- .../Classes/SshCommandTest.cs | 2 +- 44 files changed, 193 insertions(+), 193 deletions(-) diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ForwardedPortLocalTest.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ForwardedPortLocalTest.cs index e0a0696bc..50fa2a471 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ForwardedPortLocalTest.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ForwardedPortLocalTest.cs @@ -105,7 +105,7 @@ public void Test_PortForwarding_Local_Without_Connecting() using (var client = new SshClient(SshServerHostName, SshServerPort, User.UserName, User.Password)) { using var port1 = new ForwardedPortLocal("localhost", 8084, "www.renci.org", 80); - Assert.ThrowsException(() => client.AddForwardedPort(port1)); + Assert.ThrowsExactly(() => client.AddForwardedPort(port1)); } } } diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ChangeDirectory.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ChangeDirectory.cs index 2f19fd26b..eb38ab5de 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ChangeDirectory.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ChangeDirectory.cs @@ -14,7 +14,7 @@ public void Test_Sftp_ChangeDirectory_Root_Dont_Exists() using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password)) { sftp.Connect(); - Assert.ThrowsException(() => sftp.ChangeDirectory("/asdasd")); + Assert.ThrowsExactly(() => sftp.ChangeDirectory("/asdasd")); } } @@ -26,7 +26,7 @@ public async Task Test_Sftp_ChangeDirectory_Root_Dont_ExistsAsync() { await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false); - await Assert.ThrowsExceptionAsync( + await Assert.ThrowsExactlyAsync( () => sftp.ChangeDirectoryAsync("/asdasd", CancellationToken.None)); } } @@ -38,7 +38,7 @@ public void Test_Sftp_ChangeDirectory_Root_With_Slash_Dont_Exists() using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password)) { sftp.Connect(); - Assert.ThrowsException(() => sftp.ChangeDirectory("/asdasd/")); + Assert.ThrowsExactly(() => sftp.ChangeDirectory("/asdasd/")); } } @@ -50,7 +50,7 @@ public async Task Test_Sftp_ChangeDirectory_Root_With_Slash_Dont_ExistsAsync() { await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false); - await Assert.ThrowsExceptionAsync( + await Assert.ThrowsExactlyAsync( () => sftp.ChangeDirectoryAsync("/asdasd/", CancellationToken.None)); } } @@ -62,7 +62,7 @@ public void Test_Sftp_ChangeDirectory_Subfolder_Dont_Exists() using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password)) { sftp.Connect(); - Assert.ThrowsException(() => sftp.ChangeDirectory("/asdasd/sssddds")); + Assert.ThrowsExactly(() => sftp.ChangeDirectory("/asdasd/sssddds")); } } @@ -74,7 +74,7 @@ public async Task Test_Sftp_ChangeDirectory_Subfolder_Dont_ExistsAsync() { await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false); - await Assert.ThrowsExceptionAsync( + await Assert.ThrowsExactlyAsync( () => sftp.ChangeDirectoryAsync("/asdasd/sssddds", CancellationToken.None)); } } @@ -86,7 +86,7 @@ public void Test_Sftp_ChangeDirectory_Subfolder_With_Slash_Dont_Exists() using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password)) { sftp.Connect(); - Assert.ThrowsException(() => sftp.ChangeDirectory("/asdasd/sssddds/")); + Assert.ThrowsExactly(() => sftp.ChangeDirectory("/asdasd/sssddds/")); } } @@ -98,7 +98,7 @@ public async Task Test_Sftp_ChangeDirectory_Subfolder_With_Slash_Dont_ExistsAsyn { await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false); - await Assert.ThrowsExceptionAsync( + await Assert.ThrowsExactlyAsync( () => sftp.ChangeDirectoryAsync("/asdasd/sssddds/", CancellationToken.None)); } } diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.CreateDirectory.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.CreateDirectory.cs index 7274a6e91..d78abbcc0 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.CreateDirectory.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.CreateDirectory.cs @@ -30,7 +30,7 @@ public void Test_Sftp_CreateDirectory_In_Forbidden_Directory() { sftp.Connect(); - Assert.ThrowsException(() => sftp.CreateDirectory("/sbin/test")); + Assert.ThrowsExactly(() => sftp.CreateDirectory("/sbin/test")); } } @@ -42,7 +42,7 @@ public void Test_Sftp_CreateDirectory_Invalid_Path() { sftp.Connect(); - Assert.ThrowsException(() => sftp.CreateDirectory("/abcdefg/abcefg")); + Assert.ThrowsExactly(() => sftp.CreateDirectory("/abcdefg/abcefg")); } } @@ -56,7 +56,7 @@ public void Test_Sftp_CreateDirectory_Already_Exists() sftp.CreateDirectory("test"); - Assert.ThrowsException(() => sftp.CreateDirectory("test")); + Assert.ThrowsExactly(() => sftp.CreateDirectory("test")); } } } diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.DeleteDirectory.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.DeleteDirectory.cs index 0609a4572..b41763207 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.DeleteDirectory.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.DeleteDirectory.cs @@ -15,7 +15,7 @@ public void Test_Sftp_DeleteDirectory_Which_Doesnt_Exists() { sftp.Connect(); - Assert.ThrowsException(() => sftp.DeleteDirectory("abcdef")); + Assert.ThrowsExactly(() => sftp.DeleteDirectory("abcdef")); } } @@ -27,7 +27,7 @@ public void Test_Sftp_DeleteDirectory_Which_No_Permissions() { sftp.Connect(); - Assert.ThrowsException(() => sftp.DeleteDirectory("/usr")); + Assert.ThrowsExactly(() => sftp.DeleteDirectory("/usr")); } } @@ -55,7 +55,7 @@ public void Test_Sftp_DeleteDirectory_Null() { sftp.Connect(); - Assert.ThrowsException(() => sftp.DeleteDirectory(null)); + Assert.ThrowsExactly(() => sftp.DeleteDirectory(null)); } } } diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Download.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Download.cs index 1b87ecfbd..8a2be6bae 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Download.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Download.cs @@ -15,7 +15,7 @@ public void Test_Sftp_Download_Forbidden() { sftp.Connect(); - Assert.ThrowsException(() => sftp.DownloadFile("/root/.profile", Stream.Null)); + Assert.ThrowsExactly(() => sftp.DownloadFile("/root/.profile", Stream.Null)); } } @@ -27,7 +27,7 @@ public void Test_Sftp_Download_File_Not_Exists() { sftp.Connect(); - Assert.ThrowsException(() => sftp.DownloadFile("/xxx/eee/yyy", Stream.Null)); + Assert.ThrowsExactly(() => sftp.DownloadFile("/xxx/eee/yyy", Stream.Null)); } } @@ -39,7 +39,7 @@ public async Task Test_Sftp_DownloadAsync_Forbidden() { await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false); - await Assert.ThrowsExceptionAsync(() => sftp.DownloadFileAsync("/root/.profile", Stream.Null)); + await Assert.ThrowsExactlyAsync(() => sftp.DownloadFileAsync("/root/.profile", Stream.Null)); } } @@ -51,7 +51,7 @@ public async Task Test_Sftp_DownloadAsync_File_Not_Exists() { await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false); - await Assert.ThrowsExceptionAsync(() => sftp.DownloadFileAsync("/xxx/eee/yyy", Stream.Null)); + await Assert.ThrowsExactlyAsync(() => sftp.DownloadFileAsync("/xxx/eee/yyy", Stream.Null)); } } @@ -65,7 +65,7 @@ public async Task Test_Sftp_DownloadAsync_Cancellation_Requested() var cancelledToken = new CancellationToken(true); - await Assert.ThrowsExceptionAsync(() => sftp.DownloadFileAsync("/xxx/eee/yyy", Stream.Null, cancelledToken)); + await Assert.ThrowsExactlyAsync(() => sftp.DownloadFileAsync("/xxx/eee/yyy", Stream.Null, cancelledToken)); } } @@ -78,7 +78,7 @@ public void Test_Sftp_BeginDownloadFile_StreamIsNull() { sftp.Connect(); - Assert.ThrowsException(() => sftp.BeginDownloadFile("aaaa", null, null, null)); + Assert.ThrowsExactly(() => sftp.BeginDownloadFile("aaaa", null, null, null)); } } @@ -91,7 +91,7 @@ public void Test_Sftp_BeginDownloadFile_FileNameIsWhiteSpace() { sftp.Connect(); - Assert.ThrowsException(() => sftp.BeginDownloadFile(" ", Stream.Null, null, null)); + Assert.ThrowsExactly(() => sftp.BeginDownloadFile(" ", Stream.Null, null, null)); } } @@ -104,7 +104,7 @@ public void Test_Sftp_BeginDownloadFile_FileNameIsNull() { sftp.Connect(); - Assert.ThrowsException(() => sftp.BeginDownloadFile(null, Stream.Null, null, null)); + Assert.ThrowsExactly(() => sftp.BeginDownloadFile(null, Stream.Null, null, null)); } } @@ -121,7 +121,7 @@ public void Test_Sftp_EndDownloadFile_Invalid_Async_Handle() var async1 = sftp.BeginListDirectory("/", null, null); var async2 = sftp.BeginDownloadFile("test123", new MemoryStream(), null, null); - Assert.ThrowsException(() => sftp.EndDownloadFile(async1)); + Assert.ThrowsExactly(() => sftp.EndDownloadFile(async1)); } } } diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.GetAttributes.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.GetAttributes.cs index 99c4570a9..b38590578 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.GetAttributes.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.GetAttributes.cs @@ -12,7 +12,7 @@ public void Test_Sftp_GetAttributes_Not_Exists() { sftp.Connect(); - Assert.ThrowsException(() => sftp.GetAttributes("/asdfgh")); + Assert.ThrowsExactly(() => sftp.GetAttributes("/asdfgh")); } } @@ -24,7 +24,7 @@ public void Test_Sftp_GetAttributes_Null() { sftp.Connect(); - Assert.ThrowsException(() => sftp.GetAttributes(null)); + Assert.ThrowsExactly(() => sftp.GetAttributes(null)); } } diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.GetAttributesAsync.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.GetAttributesAsync.cs index 096519eff..ea4fbb24e 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.GetAttributesAsync.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.GetAttributesAsync.cs @@ -18,7 +18,7 @@ public async Task Test_Sftp_GetAttributesAsync_Not_Exists() await sftp.ConnectAsync(cts.Token); - await Assert.ThrowsExceptionAsync(async () => await sftp.GetAttributesAsync("/asdfgh", cts.Token)); + await Assert.ThrowsExactlyAsync(async () => await sftp.GetAttributesAsync("/asdfgh", cts.Token)); } } @@ -33,7 +33,7 @@ public async Task Test_Sftp_GetAttributesAsync_Null() await sftp.ConnectAsync(cts.Token); - await Assert.ThrowsExceptionAsync(async () => await sftp.GetAttributesAsync(null, cts.Token)); + await Assert.ThrowsExactlyAsync(async () => await sftp.GetAttributesAsync(null, cts.Token)); } } diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ListDirectory.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ListDirectory.cs index 2fbe6460b..f85f951e1 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ListDirectory.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ListDirectory.cs @@ -17,7 +17,7 @@ public void Test_Sftp_ListDirectory_Permission_Denied() { sftp.Connect(); - Assert.ThrowsException(() => sftp.ListDirectory("/root")); + Assert.ThrowsExactly(() => sftp.ListDirectory("/root")); } } @@ -29,7 +29,7 @@ public void Test_Sftp_ListDirectory_Not_Exists() { sftp.Connect(); - Assert.ThrowsException(() => sftp.ListDirectory("/asdfgh")); + Assert.ThrowsExactly(() => sftp.ListDirectory("/asdfgh")); } } @@ -107,7 +107,7 @@ public void Test_Sftp_ListDirectory_Null() { sftp.Connect(); - Assert.ThrowsException(() => sftp.ListDirectory(null)); + Assert.ThrowsExactly(() => sftp.ListDirectory(null)); } } @@ -283,7 +283,7 @@ public void Test_Sftp_ChangeDirectory_Null() { sftp.Connect(); - Assert.ThrowsException(() => sftp.ChangeDirectory(null)); + Assert.ThrowsExactly(() => sftp.ChangeDirectory(null)); } } @@ -296,7 +296,7 @@ public async Task Test_Sftp_ChangeDirectory_NullAsync() { await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false); - await Assert.ThrowsExceptionAsync(() => sftp.ChangeDirectoryAsync(null)); + await Assert.ThrowsExactlyAsync(() => sftp.ChangeDirectoryAsync(null)); } } @@ -312,7 +312,7 @@ public void Test_Sftp_Call_EndListDirectory_Twice() var result = sftp.EndListDirectory(ar); // TODO there is no reason that this should throw - Assert.ThrowsException(() => sftp.EndListDirectory(ar)); + Assert.ThrowsExactly(() => sftp.EndListDirectory(ar)); } } } diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.RenameFile.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.RenameFile.cs index 200e2d717..e5c527689 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.RenameFile.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.RenameFile.cs @@ -43,7 +43,7 @@ public void Test_Sftp_RenameFile_Null() { sftp.Connect(); - Assert.ThrowsException(() => sftp.RenameFile(null, null)); + Assert.ThrowsExactly(() => sftp.RenameFile(null, null)); } } } diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.RenameFileAsync.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.RenameFileAsync.cs index 321d44e1c..1939fab7b 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.RenameFileAsync.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.RenameFileAsync.cs @@ -46,7 +46,7 @@ public async Task Test_Sftp_RenameFileAsync_Null() { await sftp.ConnectAsync(default); - await Assert.ThrowsExceptionAsync(() => sftp.RenameFileAsync(null, null, default)); + await Assert.ThrowsExactlyAsync(() => sftp.RenameFileAsync(null, null, default)); } } } diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Upload.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Upload.cs index a3c626fa6..e141f19d1 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Upload.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Upload.cs @@ -109,7 +109,7 @@ public void Test_Sftp_Upload_Forbidden() using (var file = File.OpenRead(uploadedFileName)) { - Assert.ThrowsException(() => sftp.UploadFile(file, remoteFileName)); + Assert.ThrowsExactly(() => sftp.UploadFile(file, remoteFileName)); } sftp.Disconnect(); @@ -395,7 +395,7 @@ public void Test_Sftp_BeginUploadFile_StreamIsNull() { sftp.Connect(); - Assert.ThrowsException(() => sftp.BeginUploadFile(null, "aaaaa", null, null)); + Assert.ThrowsExactly(() => sftp.BeginUploadFile(null, "aaaaa", null, null)); } } @@ -408,7 +408,7 @@ public void Test_Sftp_BeginUploadFile_FileNameIsWhiteSpace() { sftp.Connect(); - Assert.ThrowsException(() => sftp.BeginUploadFile(new MemoryStream(), " ", null, null)); + Assert.ThrowsExactly(() => sftp.BeginUploadFile(new MemoryStream(), " ", null, null)); } } @@ -421,7 +421,7 @@ public void Test_Sftp_BeginUploadFile_FileNameIsNull() { sftp.Connect(); - Assert.ThrowsException(() => sftp.BeginUploadFile(new MemoryStream(), null, null, null)); + Assert.ThrowsExactly(() => sftp.BeginUploadFile(new MemoryStream(), null, null, null)); } } @@ -438,7 +438,7 @@ public void Test_Sftp_EndUploadFile_Invalid_Async_Handle() using var fileStream = File.OpenRead(filename); var async2 = sftp.BeginUploadFile(fileStream, "test", null, null); - Assert.ThrowsException(() => sftp.EndUploadFile(async1)); + Assert.ThrowsExactly(() => sftp.EndUploadFile(async1)); } } } diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpFileTest.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpFileTest.cs index 344819b33..b24b16b2d 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpFileTest.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpFileTest.cs @@ -31,7 +31,7 @@ public void Test_Get_Invalid_Directory() { sftp.Connect(); - Assert.ThrowsException(() => sftp.Get("/xyz")); + Assert.ThrowsExactly(() => sftp.Get("/xyz")); } } @@ -61,7 +61,7 @@ public void Test_Get_File_Null() { sftp.Connect(); - Assert.ThrowsException(() => sftp.Get(null)); + Assert.ThrowsExactly(() => sftp.Get(null)); } } @@ -105,7 +105,7 @@ public async Task Test_Get_Invalid_DirectoryAsync() { await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false); - await Assert.ThrowsExceptionAsync(() => sftp.GetAsync("/xyz", default)); + await Assert.ThrowsExactlyAsync(() => sftp.GetAsync("/xyz", default)); } } @@ -135,7 +135,7 @@ public async Task Test_Get_File_NullAsync() { await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false); - await Assert.ThrowsExceptionAsync(() => sftp.GetAsync(null, default)); + await Assert.ThrowsExactlyAsync(() => sftp.GetAsync(null, default)); } } diff --git a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SshCommandTest.cs b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SshCommandTest.cs index 8e3c8c6ab..e68fd7cba 100644 --- a/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SshCommandTest.cs +++ b/test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SshCommandTest.cs @@ -66,7 +66,7 @@ public void Test_CancelAsync_Unfinished_Command() cmd.CancelAsync(); - var tce = Assert.ThrowsException(() => cmd.EndExecute(asyncResult)); + var tce = Assert.ThrowsExactly(() => cmd.EndExecute(asyncResult)); Assert.AreEqual(CancellationToken.None, tce.CancellationToken); Assert.IsTrue(asyncResult.IsCompleted); Assert.IsTrue(asyncResult.AsyncWaitHandle.WaitOne(0)); @@ -90,7 +90,7 @@ public async Task Test_CancelAsync_Kill_Unfinished_Command() cmd.CancelAsync(forceKill: true); - var tce = await Assert.ThrowsExceptionAsync(() => executeTask); + var tce = await Assert.ThrowsExactlyAsync(() => executeTask); Assert.AreEqual(CancellationToken.None, tce.CancellationToken); Assert.IsTrue(asyncResult.IsCompleted); Assert.IsTrue(asyncResult.AsyncWaitHandle.WaitOne(0)); @@ -135,7 +135,7 @@ public async Task Test_ExecuteAsync_CancellationToken() await cts.CancelAsync(); - var tce = await Assert.ThrowsExceptionAsync(() => executeTask); + var tce = await Assert.ThrowsExactlyAsync(() => executeTask); Assert.AreSame(executeTask, tce.Task); Assert.AreEqual(cts.Token, tce.CancellationToken); Assert.AreEqual(string.Empty, cmd.Result); @@ -171,7 +171,7 @@ public void Test_Execute_Timeout() client.Connect(); using var cmd = client.CreateCommand("sleep 10s"); cmd.CommandTimeout = TimeSpan.FromSeconds(2); - Assert.ThrowsException(cmd.Execute); + Assert.ThrowsExactly(cmd.Execute); client.Disconnect(); } } @@ -189,7 +189,7 @@ public async Task Test_ExecuteAsync_Timeout() Assert.IsTrue(((IAsyncResult)executeTask).AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(3))); - await Assert.ThrowsExceptionAsync(() => executeTask); + await Assert.ThrowsExactlyAsync(() => executeTask); client.Disconnect(); } } @@ -209,7 +209,7 @@ public async Task Test_ExecuteAsync_Disconnect() client.Disconnect(); // Waiting for timeout is not optimal here, but better than hanging indefinitely. - await Assert.ThrowsExceptionAsync(() => executeTask); + await Assert.ThrowsExactlyAsync(() => executeTask); } } @@ -403,7 +403,7 @@ public void Test_EndExecute_Before_BeginExecute() { client.Connect(); using var cmd = client.CreateCommand("ls -l"); - Assert.ThrowsException(() => cmd.EndExecute(null)); + Assert.ThrowsExactly(() => cmd.EndExecute(null)); client.Disconnect(); } } @@ -510,7 +510,7 @@ public void Test_ExecuteAsync_Dispose_CommandFinishes() Assert.IsTrue(asyncResult.AsyncWaitHandle.WaitOne(0)); - Assert.ThrowsException(() => cmd.EndExecute(asyncResult)); + Assert.ThrowsExactly(() => cmd.EndExecute(asyncResult)); } } diff --git a/test/Renci.SshNet.IntegrationTests/ScpTests.cs b/test/Renci.SshNet.IntegrationTests/ScpTests.cs index d12d08f07..8433bf704 100644 --- a/test/Renci.SshNet.IntegrationTests/ScpTests.cs +++ b/test/Renci.SshNet.IntegrationTests/ScpTests.cs @@ -19,7 +19,7 @@ public void SetUp() _remotePathTransformation = RemotePathTransformation.ShellQuote; } - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetScpDownloadStreamDirectoryDoesNotExistData), DynamicDataSourceType.Method)] public void Scp_Download_Stream_DirectoryDoesNotExist(IRemotePathTransformation remotePathTransformation, string remotePath, @@ -93,7 +93,7 @@ public void Scp_Download_Stream_DirectoryDoesNotExist(IRemotePathTransformation } } - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetScpDownloadStreamFileDoesNotExistData), DynamicDataSourceType.Method)] public void Scp_Download_Stream_FileDoesNotExist(IRemotePathTransformation remotePathTransformation, string remotePath, @@ -169,7 +169,7 @@ public void Scp_Download_Stream_FileDoesNotExist(IRemotePathTransformation remot } } - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetScpDownloadDirectoryInfoDirectoryDoesNotExistData), DynamicDataSourceType.Method)] public void Scp_Download_DirectoryInfo_DirectoryDoesNotExist(IRemotePathTransformation remotePathTransformation, string remotePath) @@ -227,7 +227,7 @@ public void Scp_Download_DirectoryInfo_DirectoryDoesNotExist(IRemotePathTransfor } } - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetScpDownloadDirectoryInfoExistingFileData), DynamicDataSourceType.Method)] public void Scp_Download_DirectoryInfo_ExistingFile(IRemotePathTransformation remotePathTransformation, string remotePath) @@ -290,7 +290,7 @@ public void Scp_Download_DirectoryInfo_ExistingFile(IRemotePathTransformation re } } - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetScpDownloadDirectoryInfoExistingDirectoryData), DynamicDataSourceType.Method)] public void Scp_Download_DirectoryInfo_ExistingDirectory(IRemotePathTransformation remotePathTransformation, string remotePath) @@ -433,7 +433,7 @@ public void Scp_Download_DirectoryInfo_ExistingDirectory(IRemotePathTransformati } } - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetScpDownloadFileInfoDirectoryDoesNotExistData), DynamicDataSourceType.Method)] public void Scp_Download_FileInfo_DirectoryDoesNotExist(IRemotePathTransformation remotePathTransformation, string remotePath, @@ -505,7 +505,7 @@ public void Scp_Download_FileInfo_DirectoryDoesNotExist(IRemotePathTransformatio } } - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetScpDownloadFileInfoFileDoesNotExistData), DynamicDataSourceType.Method)] public void Scp_Download_FileInfo_FileDoesNotExist(IRemotePathTransformation remotePathTransformation, string remotePath, @@ -579,7 +579,7 @@ public void Scp_Download_FileInfo_FileDoesNotExist(IRemotePathTransformation rem } } - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetScpDownloadFileInfoExistingDirectoryData), DynamicDataSourceType.Method)] public void Scp_Download_FileInfo_ExistingDirectory(IRemotePathTransformation remotePathTransformation, string remotePath) @@ -648,7 +648,7 @@ public void Scp_Download_FileInfo_ExistingDirectory(IRemotePathTransformation re } } - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetScpDownloadFileInfoExistingFileData), DynamicDataSourceType.Method)] public void Scp_Download_FileInfo_ExistingFile(IRemotePathTransformation remotePathTransformation, string remotePath, @@ -740,7 +740,7 @@ public void Scp_Download_FileInfo_ExistingFile(IRemotePathTransformation remoteP } } - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetScpDownloadStreamExistingDirectoryData), DynamicDataSourceType.Method)] public void Scp_Download_Stream_ExistingDirectory(IRemotePathTransformation remotePathTransformation, string remotePath) @@ -808,7 +808,7 @@ public void Scp_Download_Stream_ExistingDirectory(IRemotePathTransformation remo } } - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetScpDownloadStreamExistingFileData), DynamicDataSourceType.Method)] public void Scp_Download_Stream_ExistingFile(IRemotePathTransformation remotePathTransformation, string remotePath, @@ -895,7 +895,7 @@ public void Scp_Download_Stream_ExistingFile(IRemotePathTransformation remotePat } } - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetScpUploadFileStreamDirectoryDoesNotExistData), DynamicDataSourceType.Method)] public void Scp_Upload_FileStream_DirectoryDoesNotExist(IRemotePathTransformation remotePathTransformation, string remotePath, @@ -965,7 +965,7 @@ public void Scp_Upload_FileStream_DirectoryDoesNotExist(IRemotePathTransformatio } } - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetScpUploadFileStreamExistingDirectoryData), DynamicDataSourceType.Method)] public void Scp_Upload_FileStream_ExistingDirectory(IRemotePathTransformation remotePathTransformation, string remoteFile) @@ -1028,7 +1028,7 @@ public void Scp_Upload_FileStream_ExistingDirectory(IRemotePathTransformation re } } - [DataTestMethod] + [TestMethod] [DynamicData(nameof(ScpUploadFileStreamExistingFileData), DynamicDataSourceType.Method)] public void Scp_Upload_FileStream_ExistingFile(IRemotePathTransformation remotePathTransformation, string remoteFile) @@ -1097,7 +1097,7 @@ public void Scp_Upload_FileStream_ExistingFile(IRemotePathTransformation remoteP } } - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetScpUploadFileStreamFileDoesNotExistData), DynamicDataSourceType.Method)] public void Scp_Upload_FileStream_FileDoesNotExist(IRemotePathTransformation remotePathTransformation, string remotePath, @@ -1196,7 +1196,7 @@ public void Scp_Upload_FileStream_FileDoesNotExist(IRemotePathTransformation rem /// /// https://github.com/sshnet/SSH.NET/issues/289 /// - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetScpUploadFileInfoDirectoryDoesNotExistData), DynamicDataSourceType.Method)] public void Scp_Upload_FileInfo_DirectoryDoesNotExist(IRemotePathTransformation remotePathTransformation, string remotePath, @@ -1276,7 +1276,7 @@ public void Scp_Upload_FileInfo_DirectoryDoesNotExist(IRemotePathTransformation /// /// https://github.com/sshnet/SSH.NET/issues/286 /// - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetScpUploadFileInfoExistingDirectoryData), DynamicDataSourceType.Method)] public void Scp_Upload_FileInfo_ExistingDirectory(IRemotePathTransformation remotePathTransformation, string remoteFile) @@ -1338,7 +1338,7 @@ public void Scp_Upload_FileInfo_ExistingDirectory(IRemotePathTransformation remo } } - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetScpUploadFileInfoExistingFileData), DynamicDataSourceType.Method)] public void Scp_Upload_FileInfo_ExistingFile(IRemotePathTransformation remotePathTransformation, string remoteFile) @@ -1416,7 +1416,7 @@ public void Scp_Upload_FileInfo_ExistingFile(IRemotePathTransformation remotePat } } - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetScpUploadFileInfoFileDoesNotExistData), DynamicDataSourceType.Method)] public void Scp_Upload_FileInfo_FileDoesNotExist(IRemotePathTransformation remotePathTransformation, string remotePath, @@ -1521,7 +1521,7 @@ public void Scp_Upload_FileInfo_FileDoesNotExist(IRemotePathTransformation remot } } - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetScpUploadDirectoryInfoDirectoryDoesNotExistData), DynamicDataSourceType.Method)] public void Scp_Upload_DirectoryInfo_DirectoryDoesNotExist(IRemotePathTransformation remotePathTransformation, string remoteDirectory) @@ -1586,7 +1586,7 @@ public void Scp_Upload_DirectoryInfo_DirectoryDoesNotExist(IRemotePathTransforma } } - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetScpUploadDirectoryInfoExistingDirectoryData), DynamicDataSourceType.Method)] public void Scp_Upload_DirectoryInfo_ExistingDirectory(IRemotePathTransformation remotePathTransformation, string remoteDirectory) @@ -1790,7 +1790,7 @@ public void Scp_Upload_DirectoryInfo_ExistingDirectory(IRemotePathTransformation } } - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetScpUploadDirectoryInfoExistingFileData), DynamicDataSourceType.Method)] public void Scp_Upload_DirectoryInfo_ExistingFile(IRemotePathTransformation remotePathTransformation, string remoteDirectory) diff --git a/test/Renci.SshNet.IntegrationTests/SftpClientTests.cs b/test/Renci.SshNet.IntegrationTests/SftpClientTests.cs index 1b43bfa11..6fffc22f6 100644 --- a/test/Renci.SshNet.IntegrationTests/SftpClientTests.cs +++ b/test/Renci.SshNet.IntegrationTests/SftpClientTests.cs @@ -104,7 +104,7 @@ public async Task Create_directory_with_contents_and_list_it_async() [TestMethod] public void Test_Sftp_ListDirectory_Permission_Denied() { - Assert.ThrowsException(() => _sftpClient.ListDirectory("/root")); + Assert.ThrowsExactly(() => _sftpClient.ListDirectory("/root")); } [TestMethod] diff --git a/test/Renci.SshNet.IntegrationTests/SftpTests.cs b/test/Renci.SshNet.IntegrationTests/SftpTests.cs index 64ca1521b..197855218 100644 --- a/test/Renci.SshNet.IntegrationTests/SftpTests.cs +++ b/test/Renci.SshNet.IntegrationTests/SftpTests.cs @@ -25,7 +25,7 @@ public void SetUp() _remotePathTransformation = RemotePathTransformation.ShellQuote; } - [DataTestMethod] + [TestMethod] [DynamicData(nameof(GetSftpUploadFileFileStreamData), DynamicDataSourceType.Method)] public void Sftp_UploadFile_FileStream(int size) { diff --git a/test/Renci.SshNet.IntegrationTests/SshClientTests.cs b/test/Renci.SshNet.IntegrationTests/SshClientTests.cs index 2a4a3fe54..ffe670afb 100644 --- a/test/Renci.SshNet.IntegrationTests/SshClientTests.cs +++ b/test/Renci.SshNet.IntegrationTests/SshClientTests.cs @@ -96,7 +96,7 @@ public void CreateInputStream_BeforeBeginExecute_ThrowsInvalidOperationException { var command = _sshClient.CreateCommand("ls"); - Assert.ThrowsException(command.CreateInputStream); + Assert.ThrowsExactly(command.CreateInputStream); } [TestMethod] @@ -106,7 +106,7 @@ public void CreateInputStream_AfterEndExecute_ThrowsInvalidOperationException() var asyncResult = command.BeginExecute(); command.EndExecute(asyncResult); - Assert.ThrowsException(command.CreateInputStream); + Assert.ThrowsExactly(command.CreateInputStream); } public void Dispose() diff --git a/test/Renci.SshNet.Tests/Classes/AbstractionsTest.cs b/test/Renci.SshNet.Tests/Classes/AbstractionsTest.cs index 90608d6b2..e79eb8561 100644 --- a/test/Renci.SshNet.Tests/Classes/AbstractionsTest.cs +++ b/test/Renci.SshNet.Tests/Classes/AbstractionsTest.cs @@ -37,7 +37,7 @@ public void CryptoAbstraction_GenerateRandom_ShouldGenerateRandomSequenceOfValue [TestMethod] public void ThreadAbstraction_ExecuteThread_ShouldThrowArgumentNullExceptionWhenActionIsNull() { - var ex = Assert.ThrowsException(() => ThreadAbstraction.ExecuteThread(null)); + var ex = Assert.ThrowsExactly(() => ThreadAbstraction.ExecuteThread(null)); Assert.IsNull(ex.InnerException); Assert.AreEqual("action", ex.ParamName); diff --git a/test/Renci.SshNet.Tests/Classes/BaseClientTest_ConnectAsync_Timeout.cs b/test/Renci.SshNet.Tests/Classes/BaseClientTest_ConnectAsync_Timeout.cs index deafc16a2..e9c775a61 100644 --- a/test/Renci.SshNet.Tests/Classes/BaseClientTest_ConnectAsync_Timeout.cs +++ b/test/Renci.SshNet.Tests/Classes/BaseClientTest_ConnectAsync_Timeout.cs @@ -48,7 +48,7 @@ public void Init() [TestMethod] public async Task ConnectAsyncWithTimeoutThrowsSshTimeoutException() { - await Assert.ThrowsExceptionAsync(() => _client.ConnectAsync(CancellationToken.None)); + await Assert.ThrowsExactlyAsync(() => _client.ConnectAsync(CancellationToken.None)); } [TestMethod] @@ -56,7 +56,7 @@ public async Task ConnectAsyncWithCancelledTokenThrowsOperationCancelledExceptio { using var cancellationTokenSource = new CancellationTokenSource(); await cancellationTokenSource.CancelAsync(); - await Assert.ThrowsExceptionAsync(() => _client.ConnectAsync(cancellationTokenSource.Token)); + await Assert.ThrowsExactlyAsync(() => _client.ConnectAsync(cancellationTokenSource.Token)); } [TestCleanup] diff --git a/test/Renci.SshNet.Tests/Classes/Common/TimeSpanExtensionsTest.cs b/test/Renci.SshNet.Tests/Classes/Common/TimeSpanExtensionsTest.cs index d53af22cf..27cd774ac 100644 --- a/test/Renci.SshNet.Tests/Classes/Common/TimeSpanExtensionsTest.cs +++ b/test/Renci.SshNet.Tests/Classes/Common/TimeSpanExtensionsTest.cs @@ -24,14 +24,14 @@ public void AsTimeout_ValidTimeSpan_ReturnsExpectedMilliseconds() public void AsTimeout_NegativeTimeSpan_ThrowsArgumentOutOfRangeException() { var timeSpan = TimeSpan.FromSeconds(-1); - Assert.ThrowsException(() => timeSpan.AsTimeout()); + Assert.ThrowsExactly(() => timeSpan.AsTimeout()); } [TestMethod] public void AsTimeout_TimeSpanExceedingMaxValue_ThrowsArgumentOutOfRangeException() { var timeSpan = TimeSpan.FromMilliseconds((double)int.MaxValue + 1); - Assert.ThrowsException(() => timeSpan.AsTimeout()); + Assert.ThrowsExactly(() => timeSpan.AsTimeout()); } [TestMethod] @@ -63,14 +63,14 @@ public void EnsureValidTimeout_ValidTimeSpan_DoesNotThrow() public void EnsureValidTimeout_NegativeTimeSpan_ThrowsArgumentOutOfRangeException() { var timeSpan = TimeSpan.FromSeconds(-1); - Assert.ThrowsException(() => timeSpan.EnsureValidTimeout()); + Assert.ThrowsExactly(() => timeSpan.EnsureValidTimeout()); } [TestMethod] public void EnsureValidTimeout_TimeSpanExceedingMaxValue_ThrowsArgumentOutOfRangeException() { var timeSpan = TimeSpan.FromMilliseconds((double)int.MaxValue + 1); - Assert.ThrowsException(() => timeSpan.EnsureValidTimeout()); + Assert.ThrowsExactly(() => timeSpan.EnsureValidTimeout()); } [TestMethod] diff --git a/test/Renci.SshNet.Tests/Classes/KeyboardInteractiveAuthenticationMethodTest.cs b/test/Renci.SshNet.Tests/Classes/KeyboardInteractiveAuthenticationMethodTest.cs index 751affe8a..03f6e3025 100644 --- a/test/Renci.SshNet.Tests/Classes/KeyboardInteractiveAuthenticationMethodTest.cs +++ b/test/Renci.SshNet.Tests/Classes/KeyboardInteractiveAuthenticationMethodTest.cs @@ -15,13 +15,13 @@ public partial class KeyboardInteractiveAuthenticationMethodTest : TestBase [TestMethod] public void Keyboard_Test_Pass_Null() { - Assert.ThrowsException(() => new KeyboardInteractiveAuthenticationMethod(null)); + Assert.ThrowsExactly(() => new KeyboardInteractiveAuthenticationMethod(null)); } [TestMethod] public void Keyboard_Test_Pass_Whitespace() { - Assert.ThrowsException(() => new KeyboardInteractiveAuthenticationMethod(string.Empty)); + Assert.ThrowsExactly(() => new KeyboardInteractiveAuthenticationMethod(string.Empty)); } } } diff --git a/test/Renci.SshNet.Tests/Classes/NoneAuthenticationMethodTest.cs b/test/Renci.SshNet.Tests/Classes/NoneAuthenticationMethodTest.cs index 705c9442d..6a22d5161 100644 --- a/test/Renci.SshNet.Tests/Classes/NoneAuthenticationMethodTest.cs +++ b/test/Renci.SshNet.Tests/Classes/NoneAuthenticationMethodTest.cs @@ -16,13 +16,13 @@ public class NoneAuthenticationMethodTest : TestBase [TestMethod] public void None_Test_Pass_Null() { - Assert.ThrowsException(() => new NoneAuthenticationMethod(null)); + Assert.ThrowsExactly(() => new NoneAuthenticationMethod(null)); } [TestMethod] public void None_Test_Pass_Whitespace() { - Assert.ThrowsException(() => new NoneAuthenticationMethod(string.Empty)); + Assert.ThrowsExactly(() => new NoneAuthenticationMethod(string.Empty)); } [TestMethod] diff --git a/test/Renci.SshNet.Tests/Classes/OrderedDictionaryTest.cs b/test/Renci.SshNet.Tests/Classes/OrderedDictionaryTest.cs index d5c55a081..9677d5bc7 100644 --- a/test/Renci.SshNet.Tests/Classes/OrderedDictionaryTest.cs +++ b/test/Renci.SshNet.Tests/Classes/OrderedDictionaryTest.cs @@ -86,22 +86,22 @@ public void NullKey_ThrowsArgumentNull() { OrderedDictionary o = new() { { "a", 4 } }; - Assert.ThrowsException(() => o[null]); - Assert.ThrowsException(() => o.Add(null, 1)); - Assert.ThrowsException(() => ((ICollection>)o).Add(new KeyValuePair(null, 1))); - Assert.ThrowsException(() => ((ICollection>)o).Contains(new KeyValuePair(null, 1))); - Assert.ThrowsException(() => o.ContainsKey(null)); - Assert.ThrowsException(() => o.IndexOf(null)); - Assert.ThrowsException(() => o.Insert(0, null, 1)); - Assert.ThrowsException(() => o.Remove(null, out _)); - Assert.ThrowsException(() => o.Remove(null)); - Assert.ThrowsException(() => ((ICollection>)o).Remove(new KeyValuePair(null, 1))); - Assert.ThrowsException(() => o.SetAt(0, null, 1)); - Assert.ThrowsException(() => o.SetPosition(null, 0)); - Assert.ThrowsException(() => o.TryAdd(null, 1)); - Assert.ThrowsException(() => o.TryAdd(null, 1, out _)); - Assert.ThrowsException(() => o.TryGetValue(null, out _)); - Assert.ThrowsException(() => o.TryGetValue(null, out _, out _)); + Assert.ThrowsExactly(() => o[null]); + Assert.ThrowsExactly(() => o.Add(null, 1)); + Assert.ThrowsExactly(() => ((ICollection>)o).Add(new KeyValuePair(null, 1))); + Assert.ThrowsExactly(() => ((ICollection>)o).Contains(new KeyValuePair(null, 1))); + Assert.ThrowsExactly(() => o.ContainsKey(null)); + Assert.ThrowsExactly(() => o.IndexOf(null)); + Assert.ThrowsExactly(() => o.Insert(0, null, 1)); + Assert.ThrowsExactly(() => o.Remove(null, out _)); + Assert.ThrowsExactly(() => o.Remove(null)); + Assert.ThrowsExactly(() => ((ICollection>)o).Remove(new KeyValuePair(null, 1))); + Assert.ThrowsExactly(() => o.SetAt(0, null, 1)); + Assert.ThrowsExactly(() => o.SetPosition(null, 0)); + Assert.ThrowsExactly(() => o.TryAdd(null, 1)); + Assert.ThrowsExactly(() => o.TryAdd(null, 1, out _)); + Assert.ThrowsExactly(() => o.TryGetValue(null, out _)); + Assert.ThrowsExactly(() => o.TryGetValue(null, out _, out _)); } [TestMethod] @@ -127,7 +127,7 @@ public void Indexer_NoMatch_GetterThrowsKeyNotFound() { OrderedDictionary o = new() { { "a", 4 } }; - Assert.ThrowsException(() => o["b"]); + Assert.ThrowsExactly(() => o["b"]); } [TestMethod] @@ -145,8 +145,8 @@ public void Add_Match() { OrderedDictionary o = new() { { "a", 4 } }; - Assert.ThrowsException(() => o.Add("a", 8)); - Assert.ThrowsException(() => ((ICollection>)o).Add(new KeyValuePair("a", 8))); + Assert.ThrowsExactly(() => o.Add("a", 8)); + Assert.ThrowsExactly(() => ((ICollection>)o).Add(new KeyValuePair("a", 8))); } [TestMethod] @@ -164,20 +164,20 @@ public void CopyTo() { OrderedDictionary o = new() { { "a", 4 }, { "b", 8 } }; - Assert.ThrowsException(() => ((ICollection>)o).CopyTo(null, 0)); - Assert.ThrowsException(() => ((ICollection>)o).CopyTo(new KeyValuePair[3], -1)); - Assert.ThrowsException(() => ((ICollection>)o).CopyTo(new KeyValuePair[3], 3)); - Assert.ThrowsException(() => ((ICollection>)o).CopyTo(new KeyValuePair[3], 2)); + Assert.ThrowsExactly(() => ((ICollection>)o).CopyTo(null, 0)); + Assert.ThrowsExactly(() => ((ICollection>)o).CopyTo(new KeyValuePair[3], -1)); + Assert.ThrowsExactly(() => ((ICollection>)o).CopyTo(new KeyValuePair[3], 3)); + Assert.ThrowsExactly(() => ((ICollection>)o).CopyTo(new KeyValuePair[3], 2)); - Assert.ThrowsException(() => o.Keys.CopyTo(null, 0)); - Assert.ThrowsException(() => o.Keys.CopyTo(new string[3], -1)); - Assert.ThrowsException(() => o.Keys.CopyTo(new string[3], 3)); - Assert.ThrowsException(() => o.Keys.CopyTo(new string[3], 2)); + Assert.ThrowsExactly(() => o.Keys.CopyTo(null, 0)); + Assert.ThrowsExactly(() => o.Keys.CopyTo(new string[3], -1)); + Assert.ThrowsExactly(() => o.Keys.CopyTo(new string[3], 3)); + Assert.ThrowsExactly(() => o.Keys.CopyTo(new string[3], 2)); - Assert.ThrowsException(() => o.Values.CopyTo(null, 0)); - Assert.ThrowsException(() => o.Values.CopyTo(new int[3], -1)); - Assert.ThrowsException(() => o.Values.CopyTo(new int[3], 3)); - Assert.ThrowsException(() => o.Values.CopyTo(new int[3], 2)); + Assert.ThrowsExactly(() => o.Values.CopyTo(null, 0)); + Assert.ThrowsExactly(() => o.Values.CopyTo(new int[3], -1)); + Assert.ThrowsExactly(() => o.Values.CopyTo(new int[3], 3)); + Assert.ThrowsExactly(() => o.Values.CopyTo(new int[3], 2)); } [TestMethod] @@ -206,9 +206,9 @@ public void GetAt_OutOfRange() { OrderedDictionary o = new() { { "a", "1" } }; - Assert.ThrowsException(() => o.GetAt(-2)); - Assert.ThrowsException(() => o.GetAt(-1)); - Assert.ThrowsException(() => o.GetAt(1)); + Assert.ThrowsExactly(() => o.GetAt(-2)); + Assert.ThrowsExactly(() => o.GetAt(-1)); + Assert.ThrowsExactly(() => o.GetAt(1)); } [TestMethod] @@ -228,21 +228,21 @@ public void SetAt() { OrderedDictionary o = new(); - Assert.ThrowsException(() => o.SetAt(-2, 1.1)); - Assert.ThrowsException(() => o.SetAt(-1, 1.1)); - Assert.ThrowsException(() => o.SetAt(0, 1.1)); - Assert.ThrowsException(() => o.SetAt(1, 1.1)); + Assert.ThrowsExactly(() => o.SetAt(-2, 1.1)); + Assert.ThrowsExactly(() => o.SetAt(-1, 1.1)); + Assert.ThrowsExactly(() => o.SetAt(0, 1.1)); + Assert.ThrowsExactly(() => o.SetAt(1, 1.1)); o.Add("a", 4); - Assert.ThrowsException(() => o.SetAt(-2, 1.1)); - Assert.ThrowsException(() => o.SetAt(-1, 1.1)); + Assert.ThrowsExactly(() => o.SetAt(-2, 1.1)); + Assert.ThrowsExactly(() => o.SetAt(-1, 1.1)); o.SetAt(0, 1.1); AssertEqual([new("a", 1.1)], o); - Assert.ThrowsException(() => o.SetAt(1, 5.5)); + Assert.ThrowsExactly(() => o.SetAt(1, 5.5)); } [TestMethod] @@ -250,8 +250,8 @@ public void SetAt3Params_OutOfRange() { OrderedDictionary o = new() { { "a", 4 }, { "b", 8 }, { "c", 12 } }; - Assert.ThrowsException(() => o.SetAt(-1, "d", 16)); - Assert.ThrowsException(() => o.SetAt(3, "d", 16)); + Assert.ThrowsExactly(() => o.SetAt(-1, "d", 16)); + Assert.ThrowsExactly(() => o.SetAt(3, "d", 16)); } [TestMethod] @@ -269,7 +269,7 @@ public void SetAt3Params_ExistingKeyDifferentIndex_Throws() { OrderedDictionary o = new() { { "a", 4 }, { "b", 8 }, { "c", 12 } }; - Assert.ThrowsException(() => o.SetAt(1, "c", 16)); + Assert.ThrowsExactly(() => o.SetAt(1, "c", 16)); } [TestMethod] @@ -287,7 +287,7 @@ public void Get_NonExistent() { OrderedDictionary o = new() { { "a", 4 } }; - Assert.ThrowsException(() => o["doesn't exist"]); + Assert.ThrowsExactly(() => o["doesn't exist"]); Assert.IsFalse(((ICollection>)o).Contains(new KeyValuePair("doesn't exist", 1))); Assert.IsFalse(o.ContainsKey("doesn't exist")); Assert.IsFalse(o.ContainsValue(999)); @@ -315,7 +315,7 @@ public void Insert() { OrderedDictionary o = new() { { "a", 4 }, { "b", 8 } }; - Assert.ThrowsException(() => o.Insert(-1, "c", 12)); + Assert.ThrowsExactly(() => o.Insert(-1, "c", 12)); o.Insert(0, "c", 12); // Start AssertEqual([new("c", 12), new("a", 4), new("b", 8)], o); @@ -326,10 +326,10 @@ public void Insert() o.Insert(o.Count, "e", 16); // End AssertEqual([new("c", 12), new("a", 4), new("d", 12), new("b", 8), new("e", 16)], o); - Assert.ThrowsException(() => o.Insert(o.Count + 1, "f", 16)); + Assert.ThrowsExactly(() => o.Insert(o.Count + 1, "f", 16)); // Existing key - Assert.ThrowsException(() => o.Insert(0, "a", 12)); + Assert.ThrowsExactly(() => o.Insert(0, "a", 12)); } [TestMethod] @@ -357,8 +357,8 @@ public void RemoveAt() { OrderedDictionary o = new() { { "a", 4 }, { "b", 8 }, { "c", 12 }, { "d", 16 } }; - Assert.ThrowsException(() => o.RemoveAt(-2)); - Assert.ThrowsException(() => o.RemoveAt(-1)); + Assert.ThrowsExactly(() => o.RemoveAt(-2)); + Assert.ThrowsExactly(() => o.RemoveAt(-1)); o.RemoveAt(0); // Start AssertEqual([new("b", 8), new("c", 12), new("d", 16)], o); @@ -369,7 +369,7 @@ public void RemoveAt() o.RemoveAt(1); // End AssertEqual([new("b", 8)], o); - Assert.ThrowsException(() => o.RemoveAt(1)); + Assert.ThrowsExactly(() => o.RemoveAt(1)); } [TestMethod] @@ -379,16 +379,16 @@ public void SetPosition_ByIndex() ArgumentOutOfRangeException ex; - ex = Assert.ThrowsException(() => o.SetPosition(-1, 0)); + ex = Assert.ThrowsExactly(() => o.SetPosition(-1, 0)); Assert.AreEqual("index", ex.ParamName); - ex = Assert.ThrowsException(() => o.SetPosition(0, -1)); + ex = Assert.ThrowsExactly(() => o.SetPosition(0, -1)); Assert.AreEqual("newIndex", ex.ParamName); - ex = Assert.ThrowsException(() => o.SetPosition(0, 4)); + ex = Assert.ThrowsExactly(() => o.SetPosition(0, 4)); Assert.AreEqual("newIndex", ex.ParamName); - ex = Assert.ThrowsException(() => o.SetPosition(4, 0)); + ex = Assert.ThrowsExactly(() => o.SetPosition(4, 0)); Assert.AreEqual("index", ex.ParamName); o.SetPosition(1, 0); @@ -418,9 +418,9 @@ public void SetPosition_ByKey() { OrderedDictionary o = new() { { "a", 4 }, { "b", 8 }, { "c", 12 }, { "d", 16 } }; - Assert.ThrowsException(() => o.SetPosition("a", -1)); - Assert.ThrowsException(() => o.SetPosition("a", 4)); - Assert.ThrowsException(() => o.SetPosition("e", 0)); + Assert.ThrowsExactly(() => o.SetPosition("a", -1)); + Assert.ThrowsExactly(() => o.SetPosition("a", 4)); + Assert.ThrowsExactly(() => o.SetPosition("e", 0)); o.SetPosition("b", 0); AssertEqual([new("b", 8), new("a", 4), new("c", 12), new("d", 16)], o); @@ -456,14 +456,14 @@ public void KeysAndValuesAreReadOnly() OrderedDictionary o = new() { { "a", 4 }, { "b", 8 } }; Assert.IsTrue(o.Keys.IsReadOnly); - Assert.ThrowsException(() => o.Keys.Add("c")); - Assert.ThrowsException(o.Keys.Clear); - Assert.ThrowsException(() => o.Keys.Remove("a")); + Assert.ThrowsExactly(() => o.Keys.Add("c")); + Assert.ThrowsExactly(o.Keys.Clear); + Assert.ThrowsExactly(() => o.Keys.Remove("a")); Assert.IsTrue(o.Values.IsReadOnly); - Assert.ThrowsException(() => o.Values.Add(12)); - Assert.ThrowsException(o.Values.Clear); - Assert.ThrowsException(() => o.Values.Remove(4)); + Assert.ThrowsExactly(() => o.Values.Add(12)); + Assert.ThrowsExactly(o.Values.Clear); + Assert.ThrowsExactly(() => o.Values.Remove(4)); } } } diff --git a/test/Renci.SshNet.Tests/Classes/PasswordAuthenticationMethodTest.cs b/test/Renci.SshNet.Tests/Classes/PasswordAuthenticationMethodTest.cs index 76d6aeb5a..820138f26 100644 --- a/test/Renci.SshNet.Tests/Classes/PasswordAuthenticationMethodTest.cs +++ b/test/Renci.SshNet.Tests/Classes/PasswordAuthenticationMethodTest.cs @@ -15,13 +15,13 @@ public partial class PasswordAuthenticationMethodTest : TestBase [TestMethod] public void Password_Test_Pass_Null_Username() { - Assert.ThrowsException(() => new PasswordAuthenticationMethod(null, "valid")); + Assert.ThrowsExactly(() => new PasswordAuthenticationMethod(null, "valid")); } [TestMethod] public void Password_Test_Pass_Null_Password() { - Assert.ThrowsException(() => new PasswordAuthenticationMethod("valid", (string)null)); + Assert.ThrowsExactly(() => new PasswordAuthenticationMethod("valid", (string)null)); } [TestMethod] @@ -33,7 +33,7 @@ public void Password_Test_Pass_Valid_Username_And_Password() [TestMethod] public void Password_Test_Pass_Whitespace() { - Assert.ThrowsException(() => new PasswordAuthenticationMethod(string.Empty, "valid")); + Assert.ThrowsExactly(() => new PasswordAuthenticationMethod(string.Empty, "valid")); } [TestMethod] diff --git a/test/Renci.SshNet.Tests/Classes/PasswordConnectionInfoTest.cs b/test/Renci.SshNet.Tests/Classes/PasswordConnectionInfoTest.cs index 9cd5cf039..75fee1303 100644 --- a/test/Renci.SshNet.Tests/Classes/PasswordConnectionInfoTest.cs +++ b/test/Renci.SshNet.Tests/Classes/PasswordConnectionInfoTest.cs @@ -33,33 +33,33 @@ public void Test_ConnectionInfo_Host_Is_Null() [TestMethod] public void Test_ConnectionInfo_Username_Is_Null() { - Assert.ThrowsException(() => new PasswordConnectionInfo(Resources.HOST, null, Resources.PASSWORD)); + Assert.ThrowsExactly(() => new PasswordConnectionInfo(Resources.HOST, null, Resources.PASSWORD)); } [TestMethod] public void Test_ConnectionInfo_Password_Is_Null() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, (string)null)); } [TestMethod] public void Test_ConnectionInfo_Username_Is_Whitespace() { - Assert.ThrowsException(() => new PasswordConnectionInfo(Resources.HOST, " ", Resources.PASSWORD)); + Assert.ThrowsExactly(() => new PasswordConnectionInfo(Resources.HOST, " ", Resources.PASSWORD)); } [TestMethod] public void Test_ConnectionInfo_SmallPortNumber() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => new PasswordConnectionInfo(Resources.HOST, IPEndPoint.MinPort - 1, Resources.USERNAME, Resources.PASSWORD)); } [TestMethod] public void Test_ConnectionInfo_BigPortNumber() { - Assert.ThrowsException( + Assert.ThrowsExactly( () => new PasswordConnectionInfo(Resources.HOST, IPEndPoint.MaxPort + 1, Resources.USERNAME, Resources.PASSWORD)); } } diff --git a/test/Renci.SshNet.Tests/Classes/PrivateKeyAuthenticationMethodTest.cs b/test/Renci.SshNet.Tests/Classes/PrivateKeyAuthenticationMethodTest.cs index aa981108f..89a79a45c 100644 --- a/test/Renci.SshNet.Tests/Classes/PrivateKeyAuthenticationMethodTest.cs +++ b/test/Renci.SshNet.Tests/Classes/PrivateKeyAuthenticationMethodTest.cs @@ -15,19 +15,19 @@ public class PrivateKeyAuthenticationMethodTest : TestBase [TestMethod] public void PrivateKey_Test_Pass_Null() { - Assert.ThrowsException(() => new PrivateKeyAuthenticationMethod(null, null)); + Assert.ThrowsExactly(() => new PrivateKeyAuthenticationMethod(null, null)); } [TestMethod] public void PrivateKey_Test_Pass_PrivateKey_Null() { - Assert.ThrowsException(() => new PrivateKeyAuthenticationMethod("username", null)); + Assert.ThrowsExactly(() => new PrivateKeyAuthenticationMethod("username", null)); } [TestMethod] public void PrivateKey_Test_Pass_Whitespace() { - Assert.ThrowsException(() => new PrivateKeyAuthenticationMethod(string.Empty, null)); + Assert.ThrowsExactly(() => new PrivateKeyAuthenticationMethod(string.Empty, null)); } } } diff --git a/test/Renci.SshNet.Tests/Classes/PrivateKeyFileTest.cs b/test/Renci.SshNet.Tests/Classes/PrivateKeyFileTest.cs index 2e5f64a3b..8a6da1e1d 100644 --- a/test/Renci.SshNet.Tests/Classes/PrivateKeyFileTest.cs +++ b/test/Renci.SshNet.Tests/Classes/PrivateKeyFileTest.cs @@ -433,7 +433,7 @@ public void Test_CertificateKeyMismatch() using (var privateKey = GetData("Key.OPENSSH.RSA.txt")) using (var certificate = GetData("Key.OPENSSH.ECDSA521-cert.pub")) { - Assert.ThrowsException(() => new PrivateKeyFile(privateKey, passPhrase: null, certificate)); + Assert.ThrowsExactly(() => new PrivateKeyFile(privateKey, passPhrase: null, certificate)); } } @@ -563,7 +563,7 @@ public void PuTTYv2_InvalidMac_ThrowsSshException() using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(pk))) { - var ex = Assert.ThrowsException(() => new PrivateKeyFile(stream)); + var ex = Assert.ThrowsExactly(() => new PrivateKeyFile(stream)); Assert.AreEqual("MAC verification failed for PuTTY key file", ex.Message); } @@ -603,7 +603,7 @@ public void PuTTYv3_InvalidMac_ThrowsSshException() using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(pk))) { - var ex = Assert.ThrowsException(() => new PrivateKeyFile(stream)); + var ex = Assert.ThrowsExactly(() => new PrivateKeyFile(stream)); Assert.AreEqual("MAC verification failed for PuTTY key file", ex.Message); } diff --git a/test/Renci.SshNet.Tests/Classes/Security/CertificateHostAlgorithmTest.cs b/test/Renci.SshNet.Tests/Classes/Security/CertificateHostAlgorithmTest.cs index 55adae4e4..fc2bee7ab 100644 --- a/test/Renci.SshNet.Tests/Classes/Security/CertificateHostAlgorithmTest.cs +++ b/test/Renci.SshNet.Tests/Classes/Security/CertificateHostAlgorithmTest.cs @@ -265,7 +265,7 @@ public void VerifySignature_NoSuppliedAlgorithms_Throws() byte[] signature = algorithm.Sign(data); - var ex = Assert.ThrowsException(() => algorithm.VerifySignature(data, signature)); + var ex = Assert.ThrowsExactly(() => algorithm.VerifySignature(data, signature)); Assert.IsTrue(ex.Message.StartsWith("Invalid usage", StringComparison.Ordinal)); } diff --git a/test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerNotResetSequenceNumberAfterNewKeys_StrictKex.cs b/test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerNotResetSequenceNumberAfterNewKeys_StrictKex.cs index 339f9df6c..33d7dda79 100644 --- a/test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerNotResetSequenceNumberAfterNewKeys_StrictKex.cs +++ b/test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerNotResetSequenceNumberAfterNewKeys_StrictKex.cs @@ -28,7 +28,7 @@ protected override bool ServerResetsSequenceAfterSendingNewKeys [TestMethod] public void ShouldThrowSshConnectionException() { - var reason = Assert.ThrowsException(Session.Connect).DisconnectReason; + var reason = Assert.ThrowsExactly(Session.Connect).DisconnectReason; Assert.AreEqual(DisconnectReason.MacError, reason); } } diff --git a/test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsDebugMessageAfterKexInit_StrictKex.cs b/test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsDebugMessageAfterKexInit_StrictKex.cs index 6fbdcceaa..257def53c 100644 --- a/test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsDebugMessageAfterKexInit_StrictKex.cs +++ b/test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsDebugMessageAfterKexInit_StrictKex.cs @@ -41,7 +41,7 @@ protected override void ActionAfterKexInit() [TestMethod] public void ShouldThrowSshException() { - var message = Assert.ThrowsException(Session.Connect).Message; + var message = Assert.ThrowsExactly(Session.Connect).Message; Assert.AreEqual("Message type 4 is not valid in the current context.", message); } } diff --git a/test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsDisconnectMessageAfterKexInit_StrictKex.cs b/test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsDisconnectMessageAfterKexInit_StrictKex.cs index 989d43e56..54b6f90b8 100644 --- a/test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsDisconnectMessageAfterKexInit_StrictKex.cs +++ b/test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsDisconnectMessageAfterKexInit_StrictKex.cs @@ -32,7 +32,7 @@ protected override void ActionAfterKexInit() [TestMethod] public void DisconnectIsAllowedDuringStrictKex() { - var exception = Assert.ThrowsException(Session.Connect); + var exception = Assert.ThrowsExactly(Session.Connect); Assert.AreEqual(DisconnectReason.TooManyConnections, exception.DisconnectReason); } } diff --git a/test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsIgnoreMessageAfterKexInit_StrictKex.cs b/test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsIgnoreMessageAfterKexInit_StrictKex.cs index 0179c0eb0..de1cc2741 100644 --- a/test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsIgnoreMessageAfterKexInit_StrictKex.cs +++ b/test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsIgnoreMessageAfterKexInit_StrictKex.cs @@ -33,7 +33,7 @@ protected override void ActionAfterKexInit() [TestMethod] public void ShouldThrowSshException() { - var message = Assert.ThrowsException(Session.Connect).Message; + var message = Assert.ThrowsExactly(Session.Connect).Message; Assert.AreEqual("Message type 2 is not valid in the current context.", message); } } diff --git a/test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsIgnoreMessageBeforeKexInit_StrictKex.cs b/test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsIgnoreMessageBeforeKexInit_StrictKex.cs index 53dde0b3c..41f00b735 100644 --- a/test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsIgnoreMessageBeforeKexInit_StrictKex.cs +++ b/test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsIgnoreMessageBeforeKexInit_StrictKex.cs @@ -33,7 +33,7 @@ protected override void ActionBeforeKexInit() [TestMethod] public void ShouldThrowSshConnectionException() { - var exception = Assert.ThrowsException(Session.Connect); + var exception = Assert.ThrowsExactly(Session.Connect); Assert.AreEqual(DisconnectReason.KeyExchangeFailed, exception.DisconnectReason); Assert.AreEqual("KEXINIT was not the first packet during strict key exchange.", exception.Message); } diff --git a/test/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteDirectory.cs b/test/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteDirectory.cs index 51a3818e2..5a47dbdc8 100644 --- a/test/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteDirectory.cs +++ b/test/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteDirectory.cs @@ -16,7 +16,7 @@ public void Test_Sftp_DeleteDirectory_Without_Connecting() { using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD)) { - Assert.ThrowsException(() => sftp.DeleteDirectory("test")); + Assert.ThrowsExactly(() => sftp.DeleteDirectory("test")); } } } diff --git a/test/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteFile.cs b/test/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteFile.cs index 20d23267a..b5c186ece 100644 --- a/test/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteFile.cs +++ b/test/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteFile.cs @@ -16,7 +16,7 @@ public void Test_Sftp_DeleteFile_Null() { using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD)) { - Assert.ThrowsException(() => sftp.DeleteFile(null)); + Assert.ThrowsExactly(() => sftp.DeleteFile(null)); } } } diff --git a/test/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteFileAsync.cs b/test/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteFileAsync.cs index 56607e13c..a3fe6b0ab 100644 --- a/test/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteFileAsync.cs +++ b/test/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteFileAsync.cs @@ -17,7 +17,7 @@ public async Task Test_Sftp_DeleteFileAsync_Null() { using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD)) { - await Assert.ThrowsExceptionAsync(() => sftp.DeleteFileAsync(null, default)); + await Assert.ThrowsExactlyAsync(() => sftp.DeleteFileAsync(null, default)); } } } diff --git a/test/Renci.SshNet.Tests/Classes/SftpClientTest.GetAttributes.cs b/test/Renci.SshNet.Tests/Classes/SftpClientTest.GetAttributes.cs index d91ce0d85..e86300371 100644 --- a/test/Renci.SshNet.Tests/Classes/SftpClientTest.GetAttributes.cs +++ b/test/Renci.SshNet.Tests/Classes/SftpClientTest.GetAttributes.cs @@ -14,7 +14,7 @@ public void GetAttributes_Throws_WhenNotConnected() { using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD)) { - Assert.ThrowsException(() => sftp.GetAttributes(".")); + Assert.ThrowsExactly(() => sftp.GetAttributes(".")); } } @@ -24,7 +24,7 @@ public void GetAttributes_Throws_WhenDisposed() var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD); sftp.Dispose(); - Assert.ThrowsException(() => sftp.GetAttributes(".")); + Assert.ThrowsExactly(() => sftp.GetAttributes(".")); } } } diff --git a/test/Renci.SshNet.Tests/Classes/SftpClientTest.GetAttributesAsync.cs b/test/Renci.SshNet.Tests/Classes/SftpClientTest.GetAttributesAsync.cs index 837307c74..39e89c84b 100644 --- a/test/Renci.SshNet.Tests/Classes/SftpClientTest.GetAttributesAsync.cs +++ b/test/Renci.SshNet.Tests/Classes/SftpClientTest.GetAttributesAsync.cs @@ -16,7 +16,7 @@ public async Task GetAttributesAsync_Throws_WhenNotConnected() { using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD)) { - await Assert.ThrowsExceptionAsync(() => sftp.GetAttributesAsync(".", CancellationToken.None)); + await Assert.ThrowsExactlyAsync(() => sftp.GetAttributesAsync(".", CancellationToken.None)); } } @@ -26,7 +26,7 @@ public async Task GetAttributesAsync_Throws_WhenDisposed() var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD); sftp.Dispose(); - await Assert.ThrowsExceptionAsync(() => sftp.GetAttributesAsync(".", CancellationToken.None)); + await Assert.ThrowsExactlyAsync(() => sftp.GetAttributesAsync(".", CancellationToken.None)); } } } diff --git a/test/Renci.SshNet.Tests/Classes/SftpClientTest.ListDirectory.cs b/test/Renci.SshNet.Tests/Classes/SftpClientTest.ListDirectory.cs index 20516a5dd..13062c6ff 100644 --- a/test/Renci.SshNet.Tests/Classes/SftpClientTest.ListDirectory.cs +++ b/test/Renci.SshNet.Tests/Classes/SftpClientTest.ListDirectory.cs @@ -16,7 +16,7 @@ public void Test_Sftp_ListDirectory_Without_Connecting() { using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD)) { - Assert.ThrowsException(() => sftp.ListDirectory(".")); + Assert.ThrowsExactly(() => sftp.ListDirectory(".")); } } } diff --git a/test/Renci.SshNet.Tests/Classes/SftpClientTest.ListDirectoryAsync.cs b/test/Renci.SshNet.Tests/Classes/SftpClientTest.ListDirectoryAsync.cs index c51fc352c..8ea7b2cbf 100644 --- a/test/Renci.SshNet.Tests/Classes/SftpClientTest.ListDirectoryAsync.cs +++ b/test/Renci.SshNet.Tests/Classes/SftpClientTest.ListDirectoryAsync.cs @@ -19,7 +19,7 @@ public async Task Test_Sftp_ListDirectoryAsync_Without_ConnectingAsync() { using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD)) { - await Assert.ThrowsExceptionAsync(async () => + await Assert.ThrowsExactlyAsync(async () => { await foreach (var x in sftp.ListDirectoryAsync(".", CancellationToken.None)) { diff --git a/test/Renci.SshNet.Tests/Classes/SftpClientTest_AsyncExceptions.cs b/test/Renci.SshNet.Tests/Classes/SftpClientTest_AsyncExceptions.cs index e138200a6..c3e5affb5 100644 --- a/test/Renci.SshNet.Tests/Classes/SftpClientTest_AsyncExceptions.cs +++ b/test/Renci.SshNet.Tests/Classes/SftpClientTest_AsyncExceptions.cs @@ -71,7 +71,7 @@ public async Task Async_ObservesSessionDisconnected() _session.InvokeDisconnected(); - var ex = await Assert.ThrowsExceptionAsync(() => openTask); + var ex = await Assert.ThrowsExactlyAsync(() => openTask); Assert.AreEqual("Connection was closed by the server.", ex.Message); } @@ -84,7 +84,7 @@ public async Task Async_ObservesChannelClosed() _session.InvokeChannelCloseReceived(); - var ex = await Assert.ThrowsExceptionAsync(() => openTask); + var ex = await Assert.ThrowsExactlyAsync(() => openTask); Assert.AreEqual("Channel was closed.", ex.Message); } @@ -99,7 +99,7 @@ public async Task Async_ObservesCancellationToken() await cts.CancelAsync(); - var ex = await Assert.ThrowsExceptionAsync(() => openTask); + var ex = await Assert.ThrowsExactlyAsync(() => openTask); Assert.AreEqual(cts.Token, ex.CancellationToken); } @@ -110,7 +110,7 @@ public async Task Async_ObservesOperationTimeout() Task openTask = _client.OpenAsync("path", FileMode.Create, FileAccess.Write, CancellationToken.None); - var ex = await Assert.ThrowsExceptionAsync(() => openTask); + var ex = await Assert.ThrowsExactlyAsync(() => openTask); } [TestMethod] @@ -124,7 +124,7 @@ public async Task Async_ObservesErrorOccurred() _session.InvokeErrorOccurred(ex); - var ex2 = await Assert.ThrowsExceptionAsync(() => openTask); + var ex2 = await Assert.ThrowsExactlyAsync(() => openTask); Assert.AreEqual(ex.Message, ex2.Message); } diff --git a/test/Renci.SshNet.Tests/Classes/ShellStreamTest.cs b/test/Renci.SshNet.Tests/Classes/ShellStreamTest.cs index 4e1f4f3fc..372b34c3d 100644 --- a/test/Renci.SshNet.Tests/Classes/ShellStreamTest.cs +++ b/test/Renci.SshNet.Tests/Classes/ShellStreamTest.cs @@ -122,7 +122,7 @@ public void Write_AfterDispose_ThrowsObjectDisposedException() var bytes = _encoding.GetBytes("Hello World!"); - Assert.ThrowsException(() => shellStream.Write(bytes, 0, bytes.Length)); + Assert.ThrowsExactly(() => shellStream.Write(bytes, 0, bytes.Length)); } [TestMethod] @@ -134,7 +134,7 @@ public void ChangeWindowSize_AfterDispose_ThrowsObjectDisposedException() shellStream.Dispose(); - Assert.ThrowsException(() => shellStream.ChangeWindowSize(80, 25, 0, 0)); + Assert.ThrowsExactly(() => shellStream.ChangeWindowSize(80, 25, 0, 0)); } [TestMethod] diff --git a/test/Renci.SshNet.Tests/Classes/ShellStreamTest_ReadExpect.cs b/test/Renci.SshNet.Tests/Classes/ShellStreamTest_ReadExpect.cs index acd903037..b4b071707 100644 --- a/test/Renci.SshNet.Tests/Classes/ShellStreamTest_ReadExpect.cs +++ b/test/Renci.SshNet.Tests/Classes/ShellStreamTest_ReadExpect.cs @@ -103,7 +103,7 @@ public void Channel_DataReceived_MoreThanBufferSize() CollectionAssert.AreEqual(expectedData, actualData.Take(expectedData.Length)); } - [DataTestMethod] + [TestMethod] [DataRow("\r\n")] [DataRow("\r")] [DataRow("\n")] @@ -149,7 +149,7 @@ public void ReadLine_DifferentTerminators() Assert.IsNull(_shellStream.ReadLine(TimeSpan.Zero)); } - [DataTestMethod] + [TestMethod] [DataRow("\r\n")] [DataRow("\r")] [DataRow("\n")] diff --git a/test/Renci.SshNet.Tests/Classes/SshCommandTest.cs b/test/Renci.SshNet.Tests/Classes/SshCommandTest.cs index d008bb789..e677f4961 100644 --- a/test/Renci.SshNet.Tests/Classes/SshCommandTest.cs +++ b/test/Renci.SshNet.Tests/Classes/SshCommandTest.cs @@ -17,7 +17,7 @@ public void Test_Execute_SingleCommand_Without_Connecting() { using (var client = new SshClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD)) { - Assert.ThrowsException(() => client.CreateCommand("echo Hello")); + Assert.ThrowsExactly(() => client.CreateCommand("echo Hello")); } } }