ソースを参照

No longer throw ObjectDisposedException in Stop() when port is disposed.

drieseng 9 年 前
コミット
5a1e469bb9

+ 1 - 17
src/Renci.SshNet.Tests/Classes/ForwardedPortDynamicTest_Stop_PortDisposed.cs

@@ -13,7 +13,6 @@ namespace Renci.SshNet.Tests.Classes
         private ForwardedPortDynamic _forwardedPort;
         private IList<EventArgs> _closingRegister;
         private IList<ExceptionEventArgs> _exceptionRegister;
-        private ObjectDisposedException _actualException;
         private IPEndPoint _endpoint;
 
         [TestInitialize]
@@ -47,22 +46,7 @@ namespace Renci.SshNet.Tests.Classes
 
         protected void Act()
         {
-            try
-            {
-                _forwardedPort.Stop();
-                Assert.Fail();
-            }
-            catch (ObjectDisposedException ex)
-            {
-                _actualException = ex;
-            }
-        }
-
-        [TestMethod]
-        public void StopShouldThrowObjectDisposedException()
-        {
-            Assert.IsNotNull(_actualException);
-            Assert.AreEqual(_forwardedPort.GetType().FullName, _actualException.ObjectName);
+            _forwardedPort.Stop();
         }
 
         [TestMethod]

+ 1 - 17
src/Renci.SshNet.Tests/Classes/ForwardedPortLocalTest_Stop_PortDisposed.cs

@@ -11,7 +11,6 @@ namespace Renci.SshNet.Tests.Classes
         private ForwardedPortLocal _forwardedPort;
         private IList<EventArgs> _closingRegister;
         private IList<ExceptionEventArgs> _exceptionRegister;
-        private ObjectDisposedException _actualException;
 
         [TestInitialize]
         public void Setup()
@@ -43,22 +42,7 @@ namespace Renci.SshNet.Tests.Classes
 
         protected void Act()
         {
-            try
-            {
-                _forwardedPort.Stop();
-                Assert.Fail();
-            }
-            catch (ObjectDisposedException ex)
-            {
-                _actualException = ex;
-            }
-        }
-
-        [TestMethod]
-        public void StopShouldThrowObjectDisposedException()
-        {
-            Assert.IsNotNull(_actualException);
-            Assert.AreEqual(_forwardedPort.GetType().FullName, _actualException.ObjectName);
+            _forwardedPort.Stop();
         }
 
         [TestMethod]

+ 1 - 17
src/Renci.SshNet.Tests/Classes/ForwardedPortRemoteTest_Stop_PortDisposed.cs

@@ -14,7 +14,6 @@ namespace Renci.SshNet.Tests.Classes
         private IPEndPoint _remoteEndpoint;
         private IList<EventArgs> _closingRegister;
         private IList<ExceptionEventArgs> _exceptionRegister;
-        private ObjectDisposedException _actualException;
 
         [TestInitialize]
         public void Setup()
@@ -49,22 +48,7 @@ namespace Renci.SshNet.Tests.Classes
 
         protected void Act()
         {
-            try
-            {
-                _forwardedPort.Stop();
-                Assert.Fail();
-            }
-            catch (ObjectDisposedException ex)
-            {
-                _actualException = ex;
-            }
-        }
-
-        [TestMethod]
-        public void StopShouldThrowObjectDisposedException()
-        {
-            Assert.IsNotNull(_actualException);
-            Assert.AreEqual(_forwardedPort.GetType().FullName, _actualException.ObjectName);
+            _forwardedPort.Stop();
         }
 
         [TestMethod]

+ 0 - 2
src/Renci.SshNet/ForwardedPort.cs

@@ -71,8 +71,6 @@ namespace Renci.SshNet
         /// </summary>
         public virtual void Stop()
         {
-            CheckDisposed();
-
             if (IsStarted)
             {
                 StopPort(Session.ConnectionInfo.Timeout);