Browse Source

Bump dependencies (#1682)

* 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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
dependabot[bot] 2 tháng trước cách đây
mục cha
commit
03ae6bfa0f
46 tập tin đã thay đổi với 199 bổ sung199 xóa
  1. 4 4
      Directory.Packages.props
  2. 1 1
      test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ForwardedPortLocalTest.cs
  3. 8 8
      test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ChangeDirectory.cs
  4. 3 3
      test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.CreateDirectory.cs
  5. 3 3
      test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.DeleteDirectory.cs
  6. 9 9
      test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Download.cs
  7. 2 2
      test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.GetAttributes.cs
  8. 2 2
      test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.GetAttributesAsync.cs
  9. 6 6
      test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ListDirectory.cs
  10. 1 1
      test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.RenameFile.cs
  11. 1 1
      test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.RenameFileAsync.cs
  12. 5 5
      test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Upload.cs
  13. 4 4
      test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpFileTest.cs
  14. 8 8
      test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SshCommandTest.cs
  15. 22 22
      test/Renci.SshNet.IntegrationTests/ScpTests.cs
  16. 1 1
      test/Renci.SshNet.IntegrationTests/SftpClientTests.cs
  17. 1 1
      test/Renci.SshNet.IntegrationTests/SftpTests.cs
  18. 2 2
      test/Renci.SshNet.IntegrationTests/SshClientTests.cs
  19. 1 1
      test/Renci.SshNet.Tests/Classes/AbstractionsTest.cs
  20. 2 2
      test/Renci.SshNet.Tests/Classes/BaseClientTest_ConnectAsync_Timeout.cs
  21. 4 4
      test/Renci.SshNet.Tests/Classes/Common/TimeSpanExtensionsTest.cs
  22. 2 2
      test/Renci.SshNet.Tests/Classes/KeyboardInteractiveAuthenticationMethodTest.cs
  23. 2 2
      test/Renci.SshNet.Tests/Classes/NoneAuthenticationMethodTest.cs
  24. 64 64
      test/Renci.SshNet.Tests/Classes/OrderedDictionaryTest.cs
  25. 3 3
      test/Renci.SshNet.Tests/Classes/PasswordAuthenticationMethodTest.cs
  26. 5 5
      test/Renci.SshNet.Tests/Classes/PasswordConnectionInfoTest.cs
  27. 3 3
      test/Renci.SshNet.Tests/Classes/PrivateKeyAuthenticationMethodTest.cs
  28. 3 3
      test/Renci.SshNet.Tests/Classes/PrivateKeyFileTest.cs
  29. 1 1
      test/Renci.SshNet.Tests/Classes/Security/CertificateHostAlgorithmTest.cs
  30. 1 1
      test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerNotResetSequenceNumberAfterNewKeys_StrictKex.cs
  31. 1 1
      test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsDebugMessageAfterKexInit_StrictKex.cs
  32. 1 1
      test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsDisconnectMessageAfterKexInit_StrictKex.cs
  33. 1 1
      test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsIgnoreMessageAfterKexInit_StrictKex.cs
  34. 1 1
      test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsIgnoreMessageBeforeKexInit_StrictKex.cs
  35. 2 2
      test/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest.cs
  36. 1 1
      test/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteDirectory.cs
  37. 1 1
      test/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteFile.cs
  38. 1 1
      test/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteFileAsync.cs
  39. 2 2
      test/Renci.SshNet.Tests/Classes/SftpClientTest.GetAttributes.cs
  40. 2 2
      test/Renci.SshNet.Tests/Classes/SftpClientTest.GetAttributesAsync.cs
  41. 1 1
      test/Renci.SshNet.Tests/Classes/SftpClientTest.ListDirectory.cs
  42. 1 1
      test/Renci.SshNet.Tests/Classes/SftpClientTest.ListDirectoryAsync.cs
  43. 5 5
      test/Renci.SshNet.Tests/Classes/SftpClientTest_AsyncExceptions.cs
  44. 2 2
      test/Renci.SshNet.Tests/Classes/ShellStreamTest.cs
  45. 2 2
      test/Renci.SshNet.Tests/Classes/ShellStreamTest_ReadExpect.cs
  46. 1 1
      test/Renci.SshNet.Tests/Classes/SshCommandTest.cs

+ 4 - 4
Directory.Packages.props

@@ -5,19 +5,19 @@
   </PropertyGroup>
   <ItemGroup>
     <PackageVersion Include="BenchmarkDotNet" Version="0.15.2" />
-    <PackageVersion Include="BouncyCastle.Cryptography" Version="2.6.1" />
+    <PackageVersion Include="BouncyCastle.Cryptography" Version="2.6.2" />
     <PackageVersion Include="coverlet.collector" Version="6.0.4" />
     <PackageVersion Include="coverlet.msbuild" Version="6.0.4" />
     <PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
-    <PackageVersion Include="Meziantou.Analyzer" Version="2.0.205" />
+    <PackageVersion Include="Meziantou.Analyzer" Version="2.0.210" />
     <!-- Should stay on LTS .NET releases. -->
     <PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.3" />
     <PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.7" />
-    <PackageVersion Include="MSTest" Version="3.9.3" />
+    <PackageVersion Include="MSTest" Version="3.10.0" />
     <PackageVersion Include="Moq" Version="4.20.72" />
     <PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.115" />
     <PackageVersion Include="PolySharp" Version="1.15.0" />
-    <PackageVersion Include="SonarAnalyzer.CSharp" Version="10.13.0.120203" />
+    <PackageVersion Include="SonarAnalyzer.CSharp" Version="10.15.0.120848" />
     <PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
     <!-- Should stay on LTS .NET releases. -->
     <PackageVersion Include="System.Formats.Asn1" Version="8.0.2" />

+ 1 - 1
test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ForwardedPortLocalTest.cs

@@ -105,7 +105,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             using (var client = new SshClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
             {
                 using var port1 = new ForwardedPortLocal("localhost", 8084, "www.renci.org", 80);
-                Assert.ThrowsException<SshConnectionException>(() => client.AddForwardedPort(port1));
+                Assert.ThrowsExactly<SshConnectionException>(() => client.AddForwardedPort(port1));
             }
         }
     }

+ 8 - 8
test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ChangeDirectory.cs

@@ -14,7 +14,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
             {
                 sftp.Connect();
-                Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.ChangeDirectory("/asdasd"));
+                Assert.ThrowsExactly<SftpPathNotFoundException>(() => sftp.ChangeDirectory("/asdasd"));
             }
         }
 
@@ -26,7 +26,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
 
-                await Assert.ThrowsExceptionAsync<SftpPathNotFoundException>(
+                await Assert.ThrowsExactlyAsync<SftpPathNotFoundException>(
                     () => sftp.ChangeDirectoryAsync("/asdasd", CancellationToken.None));
             }
         }
@@ -38,7 +38,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
             {
                 sftp.Connect();
-                Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.ChangeDirectory("/asdasd/"));
+                Assert.ThrowsExactly<SftpPathNotFoundException>(() => sftp.ChangeDirectory("/asdasd/"));
             }
         }
 
@@ -50,7 +50,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
 
-                await Assert.ThrowsExceptionAsync<SftpPathNotFoundException>(
+                await Assert.ThrowsExactlyAsync<SftpPathNotFoundException>(
                     () => sftp.ChangeDirectoryAsync("/asdasd/", CancellationToken.None));
             }
         }
@@ -62,7 +62,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
             {
                 sftp.Connect();
-                Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.ChangeDirectory("/asdasd/sssddds"));
+                Assert.ThrowsExactly<SftpPathNotFoundException>(() => sftp.ChangeDirectory("/asdasd/sssddds"));
             }
         }
 
@@ -74,7 +74,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
 
-                await Assert.ThrowsExceptionAsync<SftpPathNotFoundException>(
+                await Assert.ThrowsExactlyAsync<SftpPathNotFoundException>(
                     () => sftp.ChangeDirectoryAsync("/asdasd/sssddds", CancellationToken.None));
             }
         }
@@ -86,7 +86,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
             {
                 sftp.Connect();
-                Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.ChangeDirectory("/asdasd/sssddds/"));
+                Assert.ThrowsExactly<SftpPathNotFoundException>(() => sftp.ChangeDirectory("/asdasd/sssddds/"));
             }
         }
 
@@ -98,7 +98,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
 
-                await Assert.ThrowsExceptionAsync<SftpPathNotFoundException>(
+                await Assert.ThrowsExactlyAsync<SftpPathNotFoundException>(
                     () => sftp.ChangeDirectoryAsync("/asdasd/sssddds/", CancellationToken.None));
             }
         }

+ 3 - 3
test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.CreateDirectory.cs

@@ -30,7 +30,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<SftpPermissionDeniedException>(() => sftp.CreateDirectory("/sbin/test"));
+                Assert.ThrowsExactly<SftpPermissionDeniedException>(() => sftp.CreateDirectory("/sbin/test"));
             }
         }
 
@@ -42,7 +42,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.CreateDirectory("/abcdefg/abcefg"));
+                Assert.ThrowsExactly<SftpPathNotFoundException>(() => sftp.CreateDirectory("/abcdefg/abcefg"));
             }
         }
 
@@ -56,7 +56,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
 
                 sftp.CreateDirectory("test");
 
-                Assert.ThrowsException<SshException>(() => sftp.CreateDirectory("test"));
+                Assert.ThrowsExactly<SshException>(() => sftp.CreateDirectory("test"));
             }
         }
     }

+ 3 - 3
test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.DeleteDirectory.cs

@@ -15,7 +15,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.DeleteDirectory("abcdef"));
+                Assert.ThrowsExactly<SftpPathNotFoundException>(() => sftp.DeleteDirectory("abcdef"));
             }
         }
 
@@ -27,7 +27,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<SftpPermissionDeniedException>(() => sftp.DeleteDirectory("/usr"));
+                Assert.ThrowsExactly<SftpPermissionDeniedException>(() => sftp.DeleteDirectory("/usr"));
             }
         }
 
@@ -55,7 +55,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<ArgumentNullException>(() => sftp.DeleteDirectory(null));
+                Assert.ThrowsExactly<ArgumentNullException>(() => sftp.DeleteDirectory(null));
             }
         }
     }

+ 9 - 9
test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Download.cs

@@ -15,7 +15,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<SftpPermissionDeniedException>(() => sftp.DownloadFile("/root/.profile", Stream.Null));
+                Assert.ThrowsExactly<SftpPermissionDeniedException>(() => sftp.DownloadFile("/root/.profile", Stream.Null));
             }
         }
 
@@ -27,7 +27,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.DownloadFile("/xxx/eee/yyy", Stream.Null));
+                Assert.ThrowsExactly<SftpPathNotFoundException>(() => sftp.DownloadFile("/xxx/eee/yyy", Stream.Null));
             }
         }
 
@@ -39,7 +39,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
 
-                await Assert.ThrowsExceptionAsync<SftpPermissionDeniedException>(() => sftp.DownloadFileAsync("/root/.profile", Stream.Null));
+                await Assert.ThrowsExactlyAsync<SftpPermissionDeniedException>(() => sftp.DownloadFileAsync("/root/.profile", Stream.Null));
             }
         }
 
@@ -51,7 +51,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
 
-                await Assert.ThrowsExceptionAsync<SftpPathNotFoundException>(() => sftp.DownloadFileAsync("/xxx/eee/yyy", Stream.Null));
+                await Assert.ThrowsExactlyAsync<SftpPathNotFoundException>(() => sftp.DownloadFileAsync("/xxx/eee/yyy", Stream.Null));
             }
         }
 
@@ -65,7 +65,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
 
                 var cancelledToken = new CancellationToken(true);
 
-                await Assert.ThrowsExceptionAsync<OperationCanceledException>(() => sftp.DownloadFileAsync("/xxx/eee/yyy", Stream.Null, cancelledToken));
+                await Assert.ThrowsExactlyAsync<OperationCanceledException>(() => sftp.DownloadFileAsync("/xxx/eee/yyy", Stream.Null, cancelledToken));
             }
         }
 
@@ -78,7 +78,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<ArgumentNullException>(() => sftp.BeginDownloadFile("aaaa", null, null, null));
+                Assert.ThrowsExactly<ArgumentNullException>(() => sftp.BeginDownloadFile("aaaa", null, null, null));
             }
         }
 
@@ -91,7 +91,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<ArgumentException>(() => sftp.BeginDownloadFile("   ", Stream.Null, null, null));
+                Assert.ThrowsExactly<ArgumentException>(() => sftp.BeginDownloadFile("   ", Stream.Null, null, null));
             }
         }
 
@@ -104,7 +104,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<ArgumentNullException>(() => sftp.BeginDownloadFile(null, Stream.Null, null, null));
+                Assert.ThrowsExactly<ArgumentNullException>(() => sftp.BeginDownloadFile(null, Stream.Null, null, null));
             }
         }
 
@@ -121,7 +121,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
                 var async1 = sftp.BeginListDirectory("/", null, null);
                 var async2 = sftp.BeginDownloadFile("test123", new MemoryStream(), null, null);
 
-                Assert.ThrowsException<ArgumentException>(() => sftp.EndDownloadFile(async1));
+                Assert.ThrowsExactly<ArgumentException>(() => sftp.EndDownloadFile(async1));
             }
         }
     }

+ 2 - 2
test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.GetAttributes.cs

@@ -12,7 +12,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.GetAttributes("/asdfgh"));
+                Assert.ThrowsExactly<SftpPathNotFoundException>(() => sftp.GetAttributes("/asdfgh"));
             }
         }
 
@@ -24,7 +24,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<ArgumentNullException>(() => sftp.GetAttributes(null));
+                Assert.ThrowsExactly<ArgumentNullException>(() => sftp.GetAttributes(null));
             }
         }
 

+ 2 - 2
test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.GetAttributesAsync.cs

@@ -18,7 +18,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
 
                 await sftp.ConnectAsync(cts.Token);
 
-                await Assert.ThrowsExceptionAsync<SftpPathNotFoundException>(async () => await sftp.GetAttributesAsync("/asdfgh", cts.Token));
+                await Assert.ThrowsExactlyAsync<SftpPathNotFoundException>(async () => await sftp.GetAttributesAsync("/asdfgh", cts.Token));
             }
         }
 
@@ -33,7 +33,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
 
                 await sftp.ConnectAsync(cts.Token);
 
-                await Assert.ThrowsExceptionAsync<ArgumentNullException>(async () => await sftp.GetAttributesAsync(null, cts.Token));
+                await Assert.ThrowsExactlyAsync<ArgumentNullException>(async () => await sftp.GetAttributesAsync(null, cts.Token));
             }
         }
 

+ 6 - 6
test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ListDirectory.cs

@@ -17,7 +17,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<SftpPermissionDeniedException>(() => sftp.ListDirectory("/root"));
+                Assert.ThrowsExactly<SftpPermissionDeniedException>(() => sftp.ListDirectory("/root"));
             }
         }
 
@@ -29,7 +29,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.ListDirectory("/asdfgh"));
+                Assert.ThrowsExactly<SftpPathNotFoundException>(() => sftp.ListDirectory("/asdfgh"));
             }
         }
 
@@ -107,7 +107,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<ArgumentNullException>(() => sftp.ListDirectory(null));
+                Assert.ThrowsExactly<ArgumentNullException>(() => sftp.ListDirectory(null));
             }
         }
 
@@ -283,7 +283,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<ArgumentNullException>(() => sftp.ChangeDirectory(null));
+                Assert.ThrowsExactly<ArgumentNullException>(() => sftp.ChangeDirectory(null));
             }
         }
 
@@ -296,7 +296,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
 
-                await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => sftp.ChangeDirectoryAsync(null));
+                await Assert.ThrowsExactlyAsync<ArgumentNullException>(() => sftp.ChangeDirectoryAsync(null));
             }
         }
 
@@ -312,7 +312,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
                 var result = sftp.EndListDirectory(ar);
 
                 // TODO there is no reason that this should throw
-                Assert.ThrowsException<ArgumentException>(() => sftp.EndListDirectory(ar));
+                Assert.ThrowsExactly<ArgumentException>(() => sftp.EndListDirectory(ar));
             }
         }
     }

+ 1 - 1
test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.RenameFile.cs

@@ -43,7 +43,7 @@
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<ArgumentNullException>(() => sftp.RenameFile(null, null));
+                Assert.ThrowsExactly<ArgumentNullException>(() => sftp.RenameFile(null, null));
             }
         }
     }

+ 1 - 1
test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.RenameFileAsync.cs

@@ -46,7 +46,7 @@
             {
                 await sftp.ConnectAsync(default);
 
-                await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => sftp.RenameFileAsync(null, null, default));
+                await Assert.ThrowsExactlyAsync<ArgumentNullException>(() => sftp.RenameFileAsync(null, null, default));
             }
         }
     }

+ 5 - 5
test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.Upload.cs

@@ -109,7 +109,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
 
                 using (var file = File.OpenRead(uploadedFileName))
                 {
-                    Assert.ThrowsException<SftpPermissionDeniedException>(() => sftp.UploadFile(file, remoteFileName));
+                    Assert.ThrowsExactly<SftpPermissionDeniedException>(() => sftp.UploadFile(file, remoteFileName));
                 }
 
                 sftp.Disconnect();
@@ -395,7 +395,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<ArgumentNullException>(() => sftp.BeginUploadFile(null, "aaaaa", null, null));
+                Assert.ThrowsExactly<ArgumentNullException>(() => sftp.BeginUploadFile(null, "aaaaa", null, null));
             }
         }
 
@@ -408,7 +408,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<ArgumentException>(() => sftp.BeginUploadFile(new MemoryStream(), "   ", null, null));
+                Assert.ThrowsExactly<ArgumentException>(() => sftp.BeginUploadFile(new MemoryStream(), "   ", null, null));
             }
         }
 
@@ -421,7 +421,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<ArgumentNullException>(() => sftp.BeginUploadFile(new MemoryStream(), null, null, null));
+                Assert.ThrowsExactly<ArgumentNullException>(() => sftp.BeginUploadFile(new MemoryStream(), null, null, null));
             }
         }
 
@@ -438,7 +438,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
                 using var fileStream = File.OpenRead(filename);
                 var async2 = sftp.BeginUploadFile(fileStream, "test", null, null);
 
-                Assert.ThrowsException<ArgumentException>(() => sftp.EndUploadFile(async1));
+                Assert.ThrowsExactly<ArgumentException>(() => sftp.EndUploadFile(async1));
             }
         }
     }

+ 4 - 4
test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpFileTest.cs

@@ -31,7 +31,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.Get("/xyz"));
+                Assert.ThrowsExactly<SftpPathNotFoundException>(() => sftp.Get("/xyz"));
             }
         }
 
@@ -61,7 +61,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 sftp.Connect();
 
-                Assert.ThrowsException<ArgumentNullException>(() => sftp.Get(null));
+                Assert.ThrowsExactly<ArgumentNullException>(() => sftp.Get(null));
             }
         }
 
@@ -105,7 +105,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
 
-                await Assert.ThrowsExceptionAsync<SftpPathNotFoundException>(() => sftp.GetAsync("/xyz", default));
+                await Assert.ThrowsExactlyAsync<SftpPathNotFoundException>(() => sftp.GetAsync("/xyz", default));
             }
         }
 
@@ -135,7 +135,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
 
-                await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => sftp.GetAsync(null, default));
+                await Assert.ThrowsExactlyAsync<ArgumentNullException>(() => sftp.GetAsync(null, default));
             }
         }
 

+ 8 - 8
test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SshCommandTest.cs

@@ -66,7 +66,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
 
             cmd.CancelAsync();
 
-            var tce = Assert.ThrowsException<TaskCanceledException>(() => cmd.EndExecute(asyncResult));
+            var tce = Assert.ThrowsExactly<TaskCanceledException>(() => cmd.EndExecute(asyncResult));
             Assert.AreEqual(CancellationToken.None, tce.CancellationToken);
             Assert.IsTrue(asyncResult.IsCompleted);
             Assert.IsTrue(asyncResult.AsyncWaitHandle.WaitOne(0));
@@ -90,7 +90,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
 
             cmd.CancelAsync(forceKill: true);
 
-            var tce = await Assert.ThrowsExceptionAsync<TaskCanceledException>(() => executeTask);
+            var tce = await Assert.ThrowsExactlyAsync<TaskCanceledException>(() => executeTask);
             Assert.AreEqual(CancellationToken.None, tce.CancellationToken);
             Assert.IsTrue(asyncResult.IsCompleted);
             Assert.IsTrue(asyncResult.AsyncWaitHandle.WaitOne(0));
@@ -135,7 +135,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
 
             await cts.CancelAsync();
 
-            var tce = await Assert.ThrowsExceptionAsync<TaskCanceledException>(() => executeTask);
+            var tce = await Assert.ThrowsExactlyAsync<TaskCanceledException>(() => executeTask);
             Assert.AreSame(executeTask, tce.Task);
             Assert.AreEqual(cts.Token, tce.CancellationToken);
             Assert.AreEqual(string.Empty, cmd.Result);
@@ -171,7 +171,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
                 client.Connect();
                 using var cmd = client.CreateCommand("sleep 10s");
                 cmd.CommandTimeout = TimeSpan.FromSeconds(2);
-                Assert.ThrowsException<SshOperationTimeoutException>(cmd.Execute);
+                Assert.ThrowsExactly<SshOperationTimeoutException>(cmd.Execute);
                 client.Disconnect();
             }
         }
@@ -189,7 +189,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
 
                 Assert.IsTrue(((IAsyncResult)executeTask).AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(3)));
 
-                await Assert.ThrowsExceptionAsync<SshOperationTimeoutException>(() => executeTask);
+                await Assert.ThrowsExactlyAsync<SshOperationTimeoutException>(() => executeTask);
                 client.Disconnect();
             }
         }
@@ -209,7 +209,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
                 client.Disconnect();
 
                 // Waiting for timeout is not optimal here, but better than hanging indefinitely.
-                await Assert.ThrowsExceptionAsync<SshOperationTimeoutException>(() => executeTask);
+                await Assert.ThrowsExactlyAsync<SshOperationTimeoutException>(() => executeTask);
             }
         }
 
@@ -403,7 +403,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
             {
                 client.Connect();
                 using var cmd = client.CreateCommand("ls -l");
-                Assert.ThrowsException<ArgumentNullException>(() => cmd.EndExecute(null));
+                Assert.ThrowsExactly<ArgumentNullException>(() => cmd.EndExecute(null));
                 client.Disconnect();
             }
         }
@@ -510,7 +510,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
 
                 Assert.IsTrue(asyncResult.AsyncWaitHandle.WaitOne(0));
 
-                Assert.ThrowsException<ObjectDisposedException>(() => cmd.EndExecute(asyncResult));
+                Assert.ThrowsExactly<ObjectDisposedException>(() => cmd.EndExecute(asyncResult));
             }
         }
 

+ 22 - 22
test/Renci.SshNet.IntegrationTests/ScpTests.cs

@@ -19,7 +19,7 @@ namespace Renci.SshNet.IntegrationTests
             _remotePathTransformation = RemotePathTransformation.ShellQuote;
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetScpDownloadStreamDirectoryDoesNotExistData), DynamicDataSourceType.Method)]
         public void Scp_Download_Stream_DirectoryDoesNotExist(IRemotePathTransformation remotePathTransformation,
                                                               string remotePath,
@@ -93,7 +93,7 @@ namespace Renci.SshNet.IntegrationTests
             }
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetScpDownloadStreamFileDoesNotExistData), DynamicDataSourceType.Method)]
         public void Scp_Download_Stream_FileDoesNotExist(IRemotePathTransformation remotePathTransformation,
                                                          string remotePath,
@@ -169,7 +169,7 @@ namespace Renci.SshNet.IntegrationTests
             }
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetScpDownloadDirectoryInfoDirectoryDoesNotExistData), DynamicDataSourceType.Method)]
         public void Scp_Download_DirectoryInfo_DirectoryDoesNotExist(IRemotePathTransformation remotePathTransformation,
                                                                      string remotePath)
@@ -227,7 +227,7 @@ namespace Renci.SshNet.IntegrationTests
             }
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetScpDownloadDirectoryInfoExistingFileData), DynamicDataSourceType.Method)]
         public void Scp_Download_DirectoryInfo_ExistingFile(IRemotePathTransformation remotePathTransformation,
                                                             string remotePath)
@@ -290,7 +290,7 @@ namespace Renci.SshNet.IntegrationTests
             }
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetScpDownloadDirectoryInfoExistingDirectoryData), DynamicDataSourceType.Method)]
         public void Scp_Download_DirectoryInfo_ExistingDirectory(IRemotePathTransformation remotePathTransformation,
                                                                  string remotePath)
@@ -433,7 +433,7 @@ namespace Renci.SshNet.IntegrationTests
             }
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetScpDownloadFileInfoDirectoryDoesNotExistData), DynamicDataSourceType.Method)]
         public void Scp_Download_FileInfo_DirectoryDoesNotExist(IRemotePathTransformation remotePathTransformation,
                                                                 string remotePath,
@@ -505,7 +505,7 @@ namespace Renci.SshNet.IntegrationTests
             }
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetScpDownloadFileInfoFileDoesNotExistData), DynamicDataSourceType.Method)]
         public void Scp_Download_FileInfo_FileDoesNotExist(IRemotePathTransformation remotePathTransformation,
                                                            string remotePath,
@@ -579,7 +579,7 @@ namespace Renci.SshNet.IntegrationTests
             }
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetScpDownloadFileInfoExistingDirectoryData), DynamicDataSourceType.Method)]
         public void Scp_Download_FileInfo_ExistingDirectory(IRemotePathTransformation remotePathTransformation,
                                                             string remotePath)
@@ -648,7 +648,7 @@ namespace Renci.SshNet.IntegrationTests
             }
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetScpDownloadFileInfoExistingFileData), DynamicDataSourceType.Method)]
         public void Scp_Download_FileInfo_ExistingFile(IRemotePathTransformation remotePathTransformation,
                                                        string remotePath,
@@ -740,7 +740,7 @@ namespace Renci.SshNet.IntegrationTests
             }
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetScpDownloadStreamExistingDirectoryData), DynamicDataSourceType.Method)]
         public void Scp_Download_Stream_ExistingDirectory(IRemotePathTransformation remotePathTransformation,
                                                           string remotePath)
@@ -808,7 +808,7 @@ namespace Renci.SshNet.IntegrationTests
             }
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetScpDownloadStreamExistingFileData), DynamicDataSourceType.Method)]
         public void Scp_Download_Stream_ExistingFile(IRemotePathTransformation remotePathTransformation,
                                                      string remotePath,
@@ -895,7 +895,7 @@ namespace Renci.SshNet.IntegrationTests
             }
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetScpUploadFileStreamDirectoryDoesNotExistData), DynamicDataSourceType.Method)]
         public void Scp_Upload_FileStream_DirectoryDoesNotExist(IRemotePathTransformation remotePathTransformation,
                                                                 string remotePath,
@@ -965,7 +965,7 @@ namespace Renci.SshNet.IntegrationTests
             }
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetScpUploadFileStreamExistingDirectoryData), DynamicDataSourceType.Method)]
         public void Scp_Upload_FileStream_ExistingDirectory(IRemotePathTransformation remotePathTransformation,
                                                             string remoteFile)
@@ -1028,7 +1028,7 @@ namespace Renci.SshNet.IntegrationTests
             }
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(ScpUploadFileStreamExistingFileData), DynamicDataSourceType.Method)]
         public void Scp_Upload_FileStream_ExistingFile(IRemotePathTransformation remotePathTransformation,
                                                        string remoteFile)
@@ -1097,7 +1097,7 @@ namespace Renci.SshNet.IntegrationTests
             }
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetScpUploadFileStreamFileDoesNotExistData), DynamicDataSourceType.Method)]
         public void Scp_Upload_FileStream_FileDoesNotExist(IRemotePathTransformation remotePathTransformation,
                                                            string remotePath,
@@ -1196,7 +1196,7 @@ namespace Renci.SshNet.IntegrationTests
         /// <summary>
         /// https://github.com/sshnet/SSH.NET/issues/289
         /// </summary>
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetScpUploadFileInfoDirectoryDoesNotExistData), DynamicDataSourceType.Method)]
         public void Scp_Upload_FileInfo_DirectoryDoesNotExist(IRemotePathTransformation remotePathTransformation,
                                                               string remotePath,
@@ -1276,7 +1276,7 @@ namespace Renci.SshNet.IntegrationTests
         /// <summary>
         /// https://github.com/sshnet/SSH.NET/issues/286
         /// </summary>
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetScpUploadFileInfoExistingDirectoryData), DynamicDataSourceType.Method)]
         public void Scp_Upload_FileInfo_ExistingDirectory(IRemotePathTransformation remotePathTransformation,
                                                           string remoteFile)
@@ -1338,7 +1338,7 @@ namespace Renci.SshNet.IntegrationTests
             }
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetScpUploadFileInfoExistingFileData), DynamicDataSourceType.Method)]
         public void Scp_Upload_FileInfo_ExistingFile(IRemotePathTransformation remotePathTransformation,
                                                      string remoteFile)
@@ -1416,7 +1416,7 @@ namespace Renci.SshNet.IntegrationTests
             }
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetScpUploadFileInfoFileDoesNotExistData), DynamicDataSourceType.Method)]
         public void Scp_Upload_FileInfo_FileDoesNotExist(IRemotePathTransformation remotePathTransformation,
                                                          string remotePath,
@@ -1521,7 +1521,7 @@ namespace Renci.SshNet.IntegrationTests
             }
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetScpUploadDirectoryInfoDirectoryDoesNotExistData), DynamicDataSourceType.Method)]
         public void Scp_Upload_DirectoryInfo_DirectoryDoesNotExist(IRemotePathTransformation remotePathTransformation,
                                                                    string remoteDirectory)
@@ -1586,7 +1586,7 @@ namespace Renci.SshNet.IntegrationTests
             }
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetScpUploadDirectoryInfoExistingDirectoryData), DynamicDataSourceType.Method)]
         public void Scp_Upload_DirectoryInfo_ExistingDirectory(IRemotePathTransformation remotePathTransformation,
                                                                string remoteDirectory)
@@ -1790,7 +1790,7 @@ namespace Renci.SshNet.IntegrationTests
             }
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetScpUploadDirectoryInfoExistingFileData), DynamicDataSourceType.Method)]
         public void Scp_Upload_DirectoryInfo_ExistingFile(IRemotePathTransformation remotePathTransformation,
                                                           string remoteDirectory)

+ 1 - 1
test/Renci.SshNet.IntegrationTests/SftpClientTests.cs

@@ -104,7 +104,7 @@ namespace Renci.SshNet.IntegrationTests
         [TestMethod]
         public void Test_Sftp_ListDirectory_Permission_Denied()
         {
-            Assert.ThrowsException<SftpPermissionDeniedException>(() => _sftpClient.ListDirectory("/root"));
+            Assert.ThrowsExactly<SftpPermissionDeniedException>(() => _sftpClient.ListDirectory("/root"));
         }
 
         [TestMethod]

+ 1 - 1
test/Renci.SshNet.IntegrationTests/SftpTests.cs

@@ -25,7 +25,7 @@ namespace Renci.SshNet.IntegrationTests
             _remotePathTransformation = RemotePathTransformation.ShellQuote;
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DynamicData(nameof(GetSftpUploadFileFileStreamData), DynamicDataSourceType.Method)]
         public void Sftp_UploadFile_FileStream(int size)
         {

+ 2 - 2
test/Renci.SshNet.IntegrationTests/SshClientTests.cs

@@ -96,7 +96,7 @@ namespace Renci.SshNet.IntegrationTests
         {
             var command = _sshClient.CreateCommand("ls");
 
-            Assert.ThrowsException<InvalidOperationException>(command.CreateInputStream);
+            Assert.ThrowsExactly<InvalidOperationException>(command.CreateInputStream);
         }
 
         [TestMethod]
@@ -106,7 +106,7 @@ namespace Renci.SshNet.IntegrationTests
             var asyncResult = command.BeginExecute();
             command.EndExecute(asyncResult);
 
-            Assert.ThrowsException<InvalidOperationException>(command.CreateInputStream);
+            Assert.ThrowsExactly<InvalidOperationException>(command.CreateInputStream);
         }
 
         public void Dispose()

+ 1 - 1
test/Renci.SshNet.Tests/Classes/AbstractionsTest.cs

@@ -37,7 +37,7 @@ namespace Renci.SshNet.Tests.Classes
         [TestMethod]
         public void ThreadAbstraction_ExecuteThread_ShouldThrowArgumentNullExceptionWhenActionIsNull()
         {
-            var ex = Assert.ThrowsException<ArgumentNullException>(() => ThreadAbstraction.ExecuteThread(null));
+            var ex = Assert.ThrowsExactly<ArgumentNullException>(() => ThreadAbstraction.ExecuteThread(null));
 
             Assert.IsNull(ex.InnerException);
             Assert.AreEqual("action", ex.ParamName);

+ 2 - 2
test/Renci.SshNet.Tests/Classes/BaseClientTest_ConnectAsync_Timeout.cs

@@ -48,7 +48,7 @@ namespace Renci.SshNet.Tests.Classes
         [TestMethod]
         public async Task ConnectAsyncWithTimeoutThrowsSshTimeoutException()
         {
-            await Assert.ThrowsExceptionAsync<SshOperationTimeoutException>(() => _client.ConnectAsync(CancellationToken.None));
+            await Assert.ThrowsExactlyAsync<SshOperationTimeoutException>(() => _client.ConnectAsync(CancellationToken.None));
         }
 
         [TestMethod]
@@ -56,7 +56,7 @@ namespace Renci.SshNet.Tests.Classes
         {
             using var cancellationTokenSource = new CancellationTokenSource();
             await cancellationTokenSource.CancelAsync();
-            await Assert.ThrowsExceptionAsync<OperationCanceledException>(() => _client.ConnectAsync(cancellationTokenSource.Token));
+            await Assert.ThrowsExactlyAsync<OperationCanceledException>(() => _client.ConnectAsync(cancellationTokenSource.Token));
         }
 
         [TestCleanup]

+ 4 - 4
test/Renci.SshNet.Tests/Classes/Common/TimeSpanExtensionsTest.cs

@@ -24,14 +24,14 @@ namespace Renci.SshNet.Tests.Classes.Common
         public void AsTimeout_NegativeTimeSpan_ThrowsArgumentOutOfRangeException()
         {
             var timeSpan = TimeSpan.FromSeconds(-1);
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => timeSpan.AsTimeout());
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => timeSpan.AsTimeout());
         }
 
         [TestMethod]
         public void AsTimeout_TimeSpanExceedingMaxValue_ThrowsArgumentOutOfRangeException()
         {
             var timeSpan = TimeSpan.FromMilliseconds((double)int.MaxValue + 1);
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => timeSpan.AsTimeout());
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => timeSpan.AsTimeout());
         }
 
         [TestMethod]
@@ -63,14 +63,14 @@ namespace Renci.SshNet.Tests.Classes.Common
         public void EnsureValidTimeout_NegativeTimeSpan_ThrowsArgumentOutOfRangeException()
         {
             var timeSpan = TimeSpan.FromSeconds(-1);
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => timeSpan.EnsureValidTimeout());
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => timeSpan.EnsureValidTimeout());
         }
 
         [TestMethod]
         public void EnsureValidTimeout_TimeSpanExceedingMaxValue_ThrowsArgumentOutOfRangeException()
         {
             var timeSpan = TimeSpan.FromMilliseconds((double)int.MaxValue + 1);
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => timeSpan.EnsureValidTimeout());
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => timeSpan.EnsureValidTimeout());
         }
 
         [TestMethod]

+ 2 - 2
test/Renci.SshNet.Tests/Classes/KeyboardInteractiveAuthenticationMethodTest.cs

@@ -15,13 +15,13 @@ namespace Renci.SshNet.Tests.Classes
         [TestMethod]
         public void Keyboard_Test_Pass_Null()
         {
-            Assert.ThrowsException<ArgumentNullException>(() => new KeyboardInteractiveAuthenticationMethod(null));
+            Assert.ThrowsExactly<ArgumentNullException>(() => new KeyboardInteractiveAuthenticationMethod(null));
         }
 
         [TestMethod]
         public void Keyboard_Test_Pass_Whitespace()
         {
-            Assert.ThrowsException<ArgumentException>(() => new KeyboardInteractiveAuthenticationMethod(string.Empty));
+            Assert.ThrowsExactly<ArgumentException>(() => new KeyboardInteractiveAuthenticationMethod(string.Empty));
         }
     }
 }

+ 2 - 2
test/Renci.SshNet.Tests/Classes/NoneAuthenticationMethodTest.cs

@@ -16,13 +16,13 @@ namespace Renci.SshNet.Tests.Classes
         [TestMethod]
         public void None_Test_Pass_Null()
         {
-            Assert.ThrowsException<ArgumentNullException>(() => new NoneAuthenticationMethod(null));
+            Assert.ThrowsExactly<ArgumentNullException>(() => new NoneAuthenticationMethod(null));
         }
 
         [TestMethod]
         public void None_Test_Pass_Whitespace()
         {
-            Assert.ThrowsException<ArgumentException>(() => new NoneAuthenticationMethod(string.Empty));
+            Assert.ThrowsExactly<ArgumentException>(() => new NoneAuthenticationMethod(string.Empty));
         }
 
         [TestMethod]

+ 64 - 64
test/Renci.SshNet.Tests/Classes/OrderedDictionaryTest.cs

@@ -86,22 +86,22 @@ namespace Renci.SshNet.Tests.Classes
         {
             OrderedDictionary<string, int> o = new() { { "a", 4 } };
 
-            Assert.ThrowsException<ArgumentNullException>(() => o[null]);
-            Assert.ThrowsException<ArgumentNullException>(() => o.Add(null, 1));
-            Assert.ThrowsException<ArgumentNullException>(() => ((ICollection<KeyValuePair<string, int>>)o).Add(new KeyValuePair<string, int>(null, 1)));
-            Assert.ThrowsException<ArgumentNullException>(() => ((ICollection<KeyValuePair<string, int>>)o).Contains(new KeyValuePair<string, int>(null, 1)));
-            Assert.ThrowsException<ArgumentNullException>(() => o.ContainsKey(null));
-            Assert.ThrowsException<ArgumentNullException>(() => o.IndexOf(null));
-            Assert.ThrowsException<ArgumentNullException>(() => o.Insert(0, null, 1));
-            Assert.ThrowsException<ArgumentNullException>(() => o.Remove(null, out _));
-            Assert.ThrowsException<ArgumentNullException>(() => o.Remove(null));
-            Assert.ThrowsException<ArgumentNullException>(() => ((ICollection<KeyValuePair<string, int>>)o).Remove(new KeyValuePair<string, int>(null, 1)));
-            Assert.ThrowsException<ArgumentNullException>(() => o.SetAt(0, null, 1));
-            Assert.ThrowsException<ArgumentNullException>(() => o.SetPosition(null, 0));
-            Assert.ThrowsException<ArgumentNullException>(() => o.TryAdd(null, 1));
-            Assert.ThrowsException<ArgumentNullException>(() => o.TryAdd(null, 1, out _));
-            Assert.ThrowsException<ArgumentNullException>(() => o.TryGetValue(null, out _));
-            Assert.ThrowsException<ArgumentNullException>(() => o.TryGetValue(null, out _, out _));
+            Assert.ThrowsExactly<ArgumentNullException>(() => o[null]);
+            Assert.ThrowsExactly<ArgumentNullException>(() => o.Add(null, 1));
+            Assert.ThrowsExactly<ArgumentNullException>(() => ((ICollection<KeyValuePair<string, int>>)o).Add(new KeyValuePair<string, int>(null, 1)));
+            Assert.ThrowsExactly<ArgumentNullException>(() => ((ICollection<KeyValuePair<string, int>>)o).Contains(new KeyValuePair<string, int>(null, 1)));
+            Assert.ThrowsExactly<ArgumentNullException>(() => o.ContainsKey(null));
+            Assert.ThrowsExactly<ArgumentNullException>(() => o.IndexOf(null));
+            Assert.ThrowsExactly<ArgumentNullException>(() => o.Insert(0, null, 1));
+            Assert.ThrowsExactly<ArgumentNullException>(() => o.Remove(null, out _));
+            Assert.ThrowsExactly<ArgumentNullException>(() => o.Remove(null));
+            Assert.ThrowsExactly<ArgumentNullException>(() => ((ICollection<KeyValuePair<string, int>>)o).Remove(new KeyValuePair<string, int>(null, 1)));
+            Assert.ThrowsExactly<ArgumentNullException>(() => o.SetAt(0, null, 1));
+            Assert.ThrowsExactly<ArgumentNullException>(() => o.SetPosition(null, 0));
+            Assert.ThrowsExactly<ArgumentNullException>(() => o.TryAdd(null, 1));
+            Assert.ThrowsExactly<ArgumentNullException>(() => o.TryAdd(null, 1, out _));
+            Assert.ThrowsExactly<ArgumentNullException>(() => o.TryGetValue(null, out _));
+            Assert.ThrowsExactly<ArgumentNullException>(() => o.TryGetValue(null, out _, out _));
         }
 
         [TestMethod]
@@ -127,7 +127,7 @@ namespace Renci.SshNet.Tests.Classes
         {
             OrderedDictionary<string, int> o = new() { { "a", 4 } };
 
-            Assert.ThrowsException<KeyNotFoundException>(() => o["b"]);
+            Assert.ThrowsExactly<KeyNotFoundException>(() => o["b"]);
         }
 
         [TestMethod]
@@ -145,8 +145,8 @@ namespace Renci.SshNet.Tests.Classes
         {
             OrderedDictionary<string, int> o = new() { { "a", 4 } };
 
-            Assert.ThrowsException<ArgumentException>(() => o.Add("a", 8));
-            Assert.ThrowsException<ArgumentException>(() => ((ICollection<KeyValuePair<string, int>>)o).Add(new KeyValuePair<string, int>("a", 8)));
+            Assert.ThrowsExactly<ArgumentException>(() => o.Add("a", 8));
+            Assert.ThrowsExactly<ArgumentException>(() => ((ICollection<KeyValuePair<string, int>>)o).Add(new KeyValuePair<string, int>("a", 8)));
         }
 
         [TestMethod]
@@ -164,20 +164,20 @@ namespace Renci.SshNet.Tests.Classes
         {
             OrderedDictionary<string, int> o = new() { { "a", 4 }, { "b", 8 } };
 
-            Assert.ThrowsException<ArgumentNullException>(() => ((ICollection<KeyValuePair<string, int>>)o).CopyTo(null, 0));
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => ((ICollection<KeyValuePair<string, int>>)o).CopyTo(new KeyValuePair<string, int>[3], -1));
-            Assert.ThrowsException<ArgumentException>(() => ((ICollection<KeyValuePair<string, int>>)o).CopyTo(new KeyValuePair<string, int>[3], 3));
-            Assert.ThrowsException<ArgumentException>(() => ((ICollection<KeyValuePair<string, int>>)o).CopyTo(new KeyValuePair<string, int>[3], 2));
+            Assert.ThrowsExactly<ArgumentNullException>(() => ((ICollection<KeyValuePair<string, int>>)o).CopyTo(null, 0));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => ((ICollection<KeyValuePair<string, int>>)o).CopyTo(new KeyValuePair<string, int>[3], -1));
+            Assert.ThrowsExactly<ArgumentException>(() => ((ICollection<KeyValuePair<string, int>>)o).CopyTo(new KeyValuePair<string, int>[3], 3));
+            Assert.ThrowsExactly<ArgumentException>(() => ((ICollection<KeyValuePair<string, int>>)o).CopyTo(new KeyValuePair<string, int>[3], 2));
 
-            Assert.ThrowsException<ArgumentNullException>(() => o.Keys.CopyTo(null, 0));
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.Keys.CopyTo(new string[3], -1));
-            Assert.ThrowsException<ArgumentException>(() => o.Keys.CopyTo(new string[3], 3));
-            Assert.ThrowsException<ArgumentException>(() => o.Keys.CopyTo(new string[3], 2));
+            Assert.ThrowsExactly<ArgumentNullException>(() => o.Keys.CopyTo(null, 0));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.Keys.CopyTo(new string[3], -1));
+            Assert.ThrowsExactly<ArgumentException>(() => o.Keys.CopyTo(new string[3], 3));
+            Assert.ThrowsExactly<ArgumentException>(() => o.Keys.CopyTo(new string[3], 2));
 
-            Assert.ThrowsException<ArgumentNullException>(() => o.Values.CopyTo(null, 0));
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.Values.CopyTo(new int[3], -1));
-            Assert.ThrowsException<ArgumentException>(() => o.Values.CopyTo(new int[3], 3));
-            Assert.ThrowsException<ArgumentException>(() => o.Values.CopyTo(new int[3], 2));
+            Assert.ThrowsExactly<ArgumentNullException>(() => o.Values.CopyTo(null, 0));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.Values.CopyTo(new int[3], -1));
+            Assert.ThrowsExactly<ArgumentException>(() => o.Values.CopyTo(new int[3], 3));
+            Assert.ThrowsExactly<ArgumentException>(() => o.Values.CopyTo(new int[3], 2));
         }
 
         [TestMethod]
@@ -206,9 +206,9 @@ namespace Renci.SshNet.Tests.Classes
         {
             OrderedDictionary<string, string> o = new() { { "a", "1" } };
 
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.GetAt(-2));
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.GetAt(-1));
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.GetAt(1));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.GetAt(-2));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.GetAt(-1));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.GetAt(1));
         }
 
         [TestMethod]
@@ -228,21 +228,21 @@ namespace Renci.SshNet.Tests.Classes
         {
             OrderedDictionary<string, double> o = new();
 
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.SetAt(-2, 1.1));
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.SetAt(-1, 1.1));
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.SetAt(0, 1.1));
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.SetAt(1, 1.1));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.SetAt(-2, 1.1));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.SetAt(-1, 1.1));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.SetAt(0, 1.1));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.SetAt(1, 1.1));
 
             o.Add("a", 4);
 
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.SetAt(-2, 1.1));
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.SetAt(-1, 1.1));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.SetAt(-2, 1.1));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.SetAt(-1, 1.1));
 
             o.SetAt(0, 1.1);
 
             AssertEqual([new("a", 1.1)], o);
 
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.SetAt(1, 5.5));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.SetAt(1, 5.5));
         }
 
         [TestMethod]
@@ -250,8 +250,8 @@ namespace Renci.SshNet.Tests.Classes
         {
             OrderedDictionary<string, int> o = new() { { "a", 4 }, { "b", 8 }, { "c", 12 } };
 
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.SetAt(-1, "d", 16));
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.SetAt(3, "d", 16));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.SetAt(-1, "d", 16));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.SetAt(3, "d", 16));
         }
 
         [TestMethod]
@@ -269,7 +269,7 @@ namespace Renci.SshNet.Tests.Classes
         {
             OrderedDictionary<string, int> o = new() { { "a", 4 }, { "b", 8 }, { "c", 12 } };
 
-            Assert.ThrowsException<ArgumentException>(() => o.SetAt(1, "c", 16));
+            Assert.ThrowsExactly<ArgumentException>(() => o.SetAt(1, "c", 16));
         }
 
         [TestMethod]
@@ -287,7 +287,7 @@ namespace Renci.SshNet.Tests.Classes
         {
             OrderedDictionary<string, float> o = new() { { "a", 4 } };
 
-            Assert.ThrowsException<KeyNotFoundException>(() => o["doesn't exist"]);
+            Assert.ThrowsExactly<KeyNotFoundException>(() => o["doesn't exist"]);
             Assert.IsFalse(((ICollection<KeyValuePair<string, float>>)o).Contains(new KeyValuePair<string, float>("doesn't exist", 1)));
             Assert.IsFalse(o.ContainsKey("doesn't exist"));
             Assert.IsFalse(o.ContainsValue(999));
@@ -315,7 +315,7 @@ namespace Renci.SshNet.Tests.Classes
         {
             OrderedDictionary<string, float> o = new() { { "a", 4 }, { "b", 8 } };
 
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.Insert(-1, "c", 12));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => 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 @@ namespace Renci.SshNet.Tests.Classes
             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<ArgumentOutOfRangeException>(() => o.Insert(o.Count + 1, "f", 16));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.Insert(o.Count + 1, "f", 16));
 
             // Existing key
-            Assert.ThrowsException<ArgumentException>(() => o.Insert(0, "a", 12));
+            Assert.ThrowsExactly<ArgumentException>(() => o.Insert(0, "a", 12));
         }
 
         [TestMethod]
@@ -357,8 +357,8 @@ namespace Renci.SshNet.Tests.Classes
         {
             OrderedDictionary<string, float> o = new() { { "a", 4 }, { "b", 8 }, { "c", 12 }, { "d", 16 } };
 
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.RemoveAt(-2));
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.RemoveAt(-1));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.RemoveAt(-2));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.RemoveAt(-1));
 
             o.RemoveAt(0); // Start
             AssertEqual([new("b", 8), new("c", 12), new("d", 16)], o);
@@ -369,7 +369,7 @@ namespace Renci.SshNet.Tests.Classes
             o.RemoveAt(1); // End
             AssertEqual([new("b", 8)], o);
 
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.RemoveAt(1));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.RemoveAt(1));
         }
 
         [TestMethod]
@@ -379,16 +379,16 @@ namespace Renci.SshNet.Tests.Classes
 
             ArgumentOutOfRangeException ex;
 
-            ex = Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.SetPosition(-1, 0));
+            ex = Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.SetPosition(-1, 0));
             Assert.AreEqual("index", ex.ParamName);
 
-            ex = Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.SetPosition(0, -1));
+            ex = Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.SetPosition(0, -1));
             Assert.AreEqual("newIndex", ex.ParamName);
 
-            ex = Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.SetPosition(0, 4));
+            ex = Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.SetPosition(0, 4));
             Assert.AreEqual("newIndex", ex.ParamName);
 
-            ex = Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.SetPosition(4, 0));
+            ex = Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.SetPosition(4, 0));
             Assert.AreEqual("index", ex.ParamName);
 
             o.SetPosition(1, 0);
@@ -418,9 +418,9 @@ namespace Renci.SshNet.Tests.Classes
         {
             OrderedDictionary<string, float> o = new() { { "a", 4 }, { "b", 8 }, { "c", 12 }, { "d", 16 } };
 
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.SetPosition("a", -1));
-            Assert.ThrowsException<ArgumentOutOfRangeException>(() => o.SetPosition("a", 4));
-            Assert.ThrowsException<KeyNotFoundException>(() => o.SetPosition("e", 0));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.SetPosition("a", -1));
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => o.SetPosition("a", 4));
+            Assert.ThrowsExactly<KeyNotFoundException>(() => 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 @@ namespace Renci.SshNet.Tests.Classes
             OrderedDictionary<string, int> o = new() { { "a", 4 }, { "b", 8 } };
 
             Assert.IsTrue(o.Keys.IsReadOnly);
-            Assert.ThrowsException<NotSupportedException>(() => o.Keys.Add("c"));
-            Assert.ThrowsException<NotSupportedException>(o.Keys.Clear);
-            Assert.ThrowsException<NotSupportedException>(() => o.Keys.Remove("a"));
+            Assert.ThrowsExactly<NotSupportedException>(() => o.Keys.Add("c"));
+            Assert.ThrowsExactly<NotSupportedException>(o.Keys.Clear);
+            Assert.ThrowsExactly<NotSupportedException>(() => o.Keys.Remove("a"));
 
             Assert.IsTrue(o.Values.IsReadOnly);
-            Assert.ThrowsException<NotSupportedException>(() => o.Values.Add(12));
-            Assert.ThrowsException<NotSupportedException>(o.Values.Clear);
-            Assert.ThrowsException<NotSupportedException>(() => o.Values.Remove(4));
+            Assert.ThrowsExactly<NotSupportedException>(() => o.Values.Add(12));
+            Assert.ThrowsExactly<NotSupportedException>(o.Values.Clear);
+            Assert.ThrowsExactly<NotSupportedException>(() => o.Values.Remove(4));
         }
     }
 }

+ 3 - 3
test/Renci.SshNet.Tests/Classes/PasswordAuthenticationMethodTest.cs

@@ -15,13 +15,13 @@ namespace Renci.SshNet.Tests.Classes
         [TestMethod]
         public void Password_Test_Pass_Null_Username()
         {
-            Assert.ThrowsException<ArgumentNullException>(() => new PasswordAuthenticationMethod(null, "valid"));
+            Assert.ThrowsExactly<ArgumentNullException>(() => new PasswordAuthenticationMethod(null, "valid"));
         }
 
         [TestMethod]
         public void Password_Test_Pass_Null_Password()
         {
-            Assert.ThrowsException<ArgumentNullException>(() => new PasswordAuthenticationMethod("valid", (string)null));
+            Assert.ThrowsExactly<ArgumentNullException>(() => new PasswordAuthenticationMethod("valid", (string)null));
         }
 
         [TestMethod]
@@ -33,7 +33,7 @@ namespace Renci.SshNet.Tests.Classes
         [TestMethod]
         public void Password_Test_Pass_Whitespace()
         {
-            Assert.ThrowsException<ArgumentException>(() => new PasswordAuthenticationMethod(string.Empty, "valid"));
+            Assert.ThrowsExactly<ArgumentException>(() => new PasswordAuthenticationMethod(string.Empty, "valid"));
         }
 
         [TestMethod]

+ 5 - 5
test/Renci.SshNet.Tests/Classes/PasswordConnectionInfoTest.cs

@@ -33,33 +33,33 @@ namespace Renci.SshNet.Tests.Classes
         [TestMethod]
         public void Test_ConnectionInfo_Username_Is_Null()
         {
-            Assert.ThrowsException<ArgumentNullException>(() => new PasswordConnectionInfo(Resources.HOST, null, Resources.PASSWORD));
+            Assert.ThrowsExactly<ArgumentNullException>(() => new PasswordConnectionInfo(Resources.HOST, null, Resources.PASSWORD));
         }
 
         [TestMethod]
         public void Test_ConnectionInfo_Password_Is_Null()
         {
-            Assert.ThrowsException<ArgumentNullException>(
+            Assert.ThrowsExactly<ArgumentNullException>(
                 () => new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, (string)null));
         }
 
         [TestMethod]
         public void Test_ConnectionInfo_Username_Is_Whitespace()
         {
-            Assert.ThrowsException<ArgumentException>(() => new PasswordConnectionInfo(Resources.HOST, " ", Resources.PASSWORD));
+            Assert.ThrowsExactly<ArgumentException>(() => new PasswordConnectionInfo(Resources.HOST, " ", Resources.PASSWORD));
         }
 
         [TestMethod]
         public void Test_ConnectionInfo_SmallPortNumber()
         {
-            Assert.ThrowsException<ArgumentOutOfRangeException>(
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(
                 () => new PasswordConnectionInfo(Resources.HOST, IPEndPoint.MinPort - 1, Resources.USERNAME, Resources.PASSWORD));
         }
 
         [TestMethod]
         public void Test_ConnectionInfo_BigPortNumber()
         {
-            Assert.ThrowsException<ArgumentOutOfRangeException>(
+            Assert.ThrowsExactly<ArgumentOutOfRangeException>(
                 () => new PasswordConnectionInfo(Resources.HOST, IPEndPoint.MaxPort + 1, Resources.USERNAME, Resources.PASSWORD));
         }
     }

+ 3 - 3
test/Renci.SshNet.Tests/Classes/PrivateKeyAuthenticationMethodTest.cs

@@ -15,19 +15,19 @@ namespace Renci.SshNet.Tests.Classes
         [TestMethod]
         public void PrivateKey_Test_Pass_Null()
         {
-            Assert.ThrowsException<ArgumentNullException>(() => new PrivateKeyAuthenticationMethod(null, null));
+            Assert.ThrowsExactly<ArgumentNullException>(() => new PrivateKeyAuthenticationMethod(null, null));
         }
 
         [TestMethod]
         public void PrivateKey_Test_Pass_PrivateKey_Null()
         {
-            Assert.ThrowsException<ArgumentNullException>(() => new PrivateKeyAuthenticationMethod("username", null));
+            Assert.ThrowsExactly<ArgumentNullException>(() => new PrivateKeyAuthenticationMethod("username", null));
         }
 
         [TestMethod]
         public void PrivateKey_Test_Pass_Whitespace()
         {
-            Assert.ThrowsException<ArgumentException>(() => new PrivateKeyAuthenticationMethod(string.Empty, null));
+            Assert.ThrowsExactly<ArgumentException>(() => new PrivateKeyAuthenticationMethod(string.Empty, null));
         }
     }
 }

+ 3 - 3
test/Renci.SshNet.Tests/Classes/PrivateKeyFileTest.cs

@@ -433,7 +433,7 @@ namespace Renci.SshNet.Tests.Classes
             using (var privateKey = GetData("Key.OPENSSH.RSA.txt"))
             using (var certificate = GetData("Key.OPENSSH.ECDSA521-cert.pub"))
             {
-                Assert.ThrowsException<ArgumentException>(() => new PrivateKeyFile(privateKey, passPhrase: null, certificate));
+                Assert.ThrowsExactly<ArgumentException>(() => new PrivateKeyFile(privateKey, passPhrase: null, certificate));
             }
         }
 
@@ -563,7 +563,7 @@ namespace Renci.SshNet.Tests.Classes
 
             using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(pk)))
             {
-                var ex = Assert.ThrowsException<SshException>(() => new PrivateKeyFile(stream));
+                var ex = Assert.ThrowsExactly<SshException>(() => new PrivateKeyFile(stream));
 
                 Assert.AreEqual("MAC verification failed for PuTTY key file", ex.Message);
             }
@@ -603,7 +603,7 @@ namespace Renci.SshNet.Tests.Classes
 
             using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(pk)))
             {
-                var ex = Assert.ThrowsException<SshException>(() => new PrivateKeyFile(stream));
+                var ex = Assert.ThrowsExactly<SshException>(() => new PrivateKeyFile(stream));
 
                 Assert.AreEqual("MAC verification failed for PuTTY key file", ex.Message);
             }

+ 1 - 1
test/Renci.SshNet.Tests/Classes/Security/CertificateHostAlgorithmTest.cs

@@ -265,7 +265,7 @@ namespace Renci.SshNet.Tests.Classes.Security
 
             byte[] signature = algorithm.Sign(data);
 
-            var ex = Assert.ThrowsException<InvalidOperationException>(() => algorithm.VerifySignature(data, signature));
+            var ex = Assert.ThrowsExactly<InvalidOperationException>(() => algorithm.VerifySignature(data, signature));
             Assert.IsTrue(ex.Message.StartsWith("Invalid usage", StringComparison.Ordinal));
         }
 

+ 1 - 1
test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerNotResetSequenceNumberAfterNewKeys_StrictKex.cs

@@ -28,7 +28,7 @@ namespace Renci.SshNet.Tests.Classes
         [TestMethod]
         public void ShouldThrowSshConnectionException()
         {
-            var reason = Assert.ThrowsException<SshConnectionException>(Session.Connect).DisconnectReason;
+            var reason = Assert.ThrowsExactly<SshConnectionException>(Session.Connect).DisconnectReason;
             Assert.AreEqual(DisconnectReason.MacError, reason);
         }
     }

+ 1 - 1
test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsDebugMessageAfterKexInit_StrictKex.cs

@@ -41,7 +41,7 @@ namespace Renci.SshNet.Tests.Classes
         [TestMethod]
         public void ShouldThrowSshException()
         {
-            var message = Assert.ThrowsException<SshException>(Session.Connect).Message;
+            var message = Assert.ThrowsExactly<SshException>(Session.Connect).Message;
             Assert.AreEqual("Message type 4 is not valid in the current context.", message);
         }
     }

+ 1 - 1
test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsDisconnectMessageAfterKexInit_StrictKex.cs

@@ -32,7 +32,7 @@ namespace Renci.SshNet.Tests.Classes
         [TestMethod]
         public void DisconnectIsAllowedDuringStrictKex()
         {
-            var exception = Assert.ThrowsException<SshConnectionException>(Session.Connect);
+            var exception = Assert.ThrowsExactly<SshConnectionException>(Session.Connect);
             Assert.AreEqual(DisconnectReason.TooManyConnections, exception.DisconnectReason);
         }
     }

+ 1 - 1
test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsIgnoreMessageAfterKexInit_StrictKex.cs

@@ -33,7 +33,7 @@ namespace Renci.SshNet.Tests.Classes
         [TestMethod]
         public void ShouldThrowSshException()
         {
-            var message = Assert.ThrowsException<SshException>(Session.Connect).Message;
+            var message = Assert.ThrowsExactly<SshException>(Session.Connect).Message;
             Assert.AreEqual("Message type 2 is not valid in the current context.", message);
         }
     }

+ 1 - 1
test/Renci.SshNet.Tests/Classes/SessionTest_Connecting_ServerSendsIgnoreMessageBeforeKexInit_StrictKex.cs

@@ -33,7 +33,7 @@ namespace Renci.SshNet.Tests.Classes
         [TestMethod]
         public void ShouldThrowSshConnectionException()
         {
-            var exception = Assert.ThrowsException<SshConnectionException>(Session.Connect);
+            var exception = Assert.ThrowsExactly<SshConnectionException>(Session.Connect);
             Assert.AreEqual(DisconnectReason.KeyExchangeFailed, exception.DisconnectReason);
             Assert.AreEqual("KEXINIT was not the first packet during strict key exchange.", exception.Message);
         }

+ 2 - 2
test/Renci.SshNet.Tests/Classes/Sftp/SftpFileStreamTest.cs

@@ -17,7 +17,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp
     [TestClass]
     public class SftpFileStreamTest
     {
-        [DataTestMethod]
+        [TestMethod]
         [DataRow(false)]
         [DataRow(true)]
         public async Task BadFileMode_ThrowsArgumentOutOfRangeException(bool isAsync)
@@ -38,7 +38,7 @@ namespace Renci.SshNet.Tests.Classes.Sftp
             Assert.AreEqual("mode", ex.ParamName);
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DataRow(false)]
         [DataRow(true)]
         public async Task BadFileAccess_ThrowsArgumentOutOfRangeException(bool isAsync)

+ 1 - 1
test/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteDirectory.cs

@@ -16,7 +16,7 @@ namespace Renci.SshNet.Tests.Classes
         {
             using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
             {
-                Assert.ThrowsException<SshConnectionException>(() => sftp.DeleteDirectory("test"));
+                Assert.ThrowsExactly<SshConnectionException>(() => sftp.DeleteDirectory("test"));
             }
         }
     }

+ 1 - 1
test/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteFile.cs

@@ -16,7 +16,7 @@ namespace Renci.SshNet.Tests.Classes
         {
             using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
             {
-                Assert.ThrowsException<ArgumentNullException>(() => sftp.DeleteFile(null));
+                Assert.ThrowsExactly<ArgumentNullException>(() => sftp.DeleteFile(null));
             }
         }
     }

+ 1 - 1
test/Renci.SshNet.Tests/Classes/SftpClientTest.DeleteFileAsync.cs

@@ -17,7 +17,7 @@ namespace Renci.SshNet.Tests.Classes
         {
             using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
             {
-                await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => sftp.DeleteFileAsync(null, default));
+                await Assert.ThrowsExactlyAsync<ArgumentNullException>(() => sftp.DeleteFileAsync(null, default));
             }
         }
     }

+ 2 - 2
test/Renci.SshNet.Tests/Classes/SftpClientTest.GetAttributes.cs

@@ -14,7 +14,7 @@ namespace Renci.SshNet.Tests.Classes
         {
             using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
             {
-                Assert.ThrowsException<SshConnectionException>(() => sftp.GetAttributes("."));
+                Assert.ThrowsExactly<SshConnectionException>(() => sftp.GetAttributes("."));
             }
         }
 
@@ -24,7 +24,7 @@ namespace Renci.SshNet.Tests.Classes
             var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD);
             sftp.Dispose();
 
-            Assert.ThrowsException<ObjectDisposedException>(() => sftp.GetAttributes("."));
+            Assert.ThrowsExactly<ObjectDisposedException>(() => sftp.GetAttributes("."));
         }
     }
 }

+ 2 - 2
test/Renci.SshNet.Tests/Classes/SftpClientTest.GetAttributesAsync.cs

@@ -16,7 +16,7 @@ namespace Renci.SshNet.Tests.Classes
         {
             using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
             {
-                await Assert.ThrowsExceptionAsync<SshConnectionException>(() => sftp.GetAttributesAsync(".", CancellationToken.None));
+                await Assert.ThrowsExactlyAsync<SshConnectionException>(() => sftp.GetAttributesAsync(".", CancellationToken.None));
             }
         }
 
@@ -26,7 +26,7 @@ namespace Renci.SshNet.Tests.Classes
             var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD);
             sftp.Dispose();
 
-            await Assert.ThrowsExceptionAsync<ObjectDisposedException>(() => sftp.GetAttributesAsync(".", CancellationToken.None));
+            await Assert.ThrowsExactlyAsync<ObjectDisposedException>(() => sftp.GetAttributesAsync(".", CancellationToken.None));
         }
     }
 }

+ 1 - 1
test/Renci.SshNet.Tests/Classes/SftpClientTest.ListDirectory.cs

@@ -16,7 +16,7 @@ namespace Renci.SshNet.Tests.Classes
         {
             using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
             {
-                Assert.ThrowsException<SshConnectionException>(() => sftp.ListDirectory("."));
+                Assert.ThrowsExactly<SshConnectionException>(() => sftp.ListDirectory("."));
             }
         }
     }

+ 1 - 1
test/Renci.SshNet.Tests/Classes/SftpClientTest.ListDirectoryAsync.cs

@@ -19,7 +19,7 @@ namespace Renci.SshNet.Tests.Classes
         {
             using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
             {
-                await Assert.ThrowsExceptionAsync<SshConnectionException>(async () =>
+                await Assert.ThrowsExactlyAsync<SshConnectionException>(async () =>
                 {
                     await foreach (var x in sftp.ListDirectoryAsync(".", CancellationToken.None))
                     {

+ 5 - 5
test/Renci.SshNet.Tests/Classes/SftpClientTest_AsyncExceptions.cs

@@ -71,7 +71,7 @@ namespace Renci.SshNet.Tests.Classes
 
             _session.InvokeDisconnected();
 
-            var ex = await Assert.ThrowsExceptionAsync<SshException>(() => openTask);
+            var ex = await Assert.ThrowsExactlyAsync<SshException>(() => openTask);
             Assert.AreEqual("Connection was closed by the server.", ex.Message);
         }
 
@@ -84,7 +84,7 @@ namespace Renci.SshNet.Tests.Classes
 
             _session.InvokeChannelCloseReceived();
 
-            var ex = await Assert.ThrowsExceptionAsync<SshException>(() => openTask);
+            var ex = await Assert.ThrowsExactlyAsync<SshException>(() => openTask);
             Assert.AreEqual("Channel was closed.", ex.Message);
         }
 
@@ -99,7 +99,7 @@ namespace Renci.SshNet.Tests.Classes
 
             await cts.CancelAsync();
 
-            var ex = await Assert.ThrowsExceptionAsync<TaskCanceledException>(() => openTask);
+            var ex = await Assert.ThrowsExactlyAsync<TaskCanceledException>(() => openTask);
             Assert.AreEqual(cts.Token, ex.CancellationToken);
         }
 
@@ -110,7 +110,7 @@ namespace Renci.SshNet.Tests.Classes
 
             Task<SftpFileStream> openTask = _client.OpenAsync("path", FileMode.Create, FileAccess.Write, CancellationToken.None);
 
-            var ex = await Assert.ThrowsExceptionAsync<SshOperationTimeoutException>(() => openTask);
+            var ex = await Assert.ThrowsExactlyAsync<SshOperationTimeoutException>(() => openTask);
         }
 
         [TestMethod]
@@ -124,7 +124,7 @@ namespace Renci.SshNet.Tests.Classes
 
             _session.InvokeErrorOccurred(ex);
 
-            var ex2 = await Assert.ThrowsExceptionAsync<MyException>(() => openTask);
+            var ex2 = await Assert.ThrowsExactlyAsync<MyException>(() => openTask);
             Assert.AreEqual(ex.Message, ex2.Message);
         }
 

+ 2 - 2
test/Renci.SshNet.Tests/Classes/ShellStreamTest.cs

@@ -122,7 +122,7 @@ namespace Renci.SshNet.Tests.Classes
 
             var bytes = _encoding.GetBytes("Hello World!");
 
-            Assert.ThrowsException<ObjectDisposedException>(() => shellStream.Write(bytes, 0, bytes.Length));
+            Assert.ThrowsExactly<ObjectDisposedException>(() => shellStream.Write(bytes, 0, bytes.Length));
         }
 
         [TestMethod]
@@ -134,7 +134,7 @@ namespace Renci.SshNet.Tests.Classes
 
             shellStream.Dispose();
 
-            Assert.ThrowsException<ObjectDisposedException>(() => shellStream.ChangeWindowSize(80, 25, 0, 0));
+            Assert.ThrowsExactly<ObjectDisposedException>(() => shellStream.ChangeWindowSize(80, 25, 0, 0));
         }
 
         [TestMethod]

+ 2 - 2
test/Renci.SshNet.Tests/Classes/ShellStreamTest_ReadExpect.cs

@@ -103,7 +103,7 @@ namespace Renci.SshNet.Tests.Classes
             CollectionAssert.AreEqual(expectedData, actualData.Take(expectedData.Length));
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DataRow("\r\n")]
         [DataRow("\r")]
         [DataRow("\n")]
@@ -149,7 +149,7 @@ namespace Renci.SshNet.Tests.Classes
             Assert.IsNull(_shellStream.ReadLine(TimeSpan.Zero));
         }
 
-        [DataTestMethod]
+        [TestMethod]
         [DataRow("\r\n")]
         [DataRow("\r")]
         [DataRow("\n")]

+ 1 - 1
test/Renci.SshNet.Tests/Classes/SshCommandTest.cs

@@ -17,7 +17,7 @@ namespace Renci.SshNet.Tests.Classes
         {
             using (var client = new SshClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
             {
-                Assert.ThrowsException<SshConnectionException>(() => client.CreateCommand("echo Hello"));
+                Assert.ThrowsExactly<SshConnectionException>(() => client.CreateCommand("echo Hello"));
             }
         }
     }