Skip to content

Commit 23168f4

Browse files
committed
Merge remote-tracking branch 'remotes/origin/develop'
2 parents fc114fb + c5b487c commit 23168f4

File tree

2 files changed

+124
-121
lines changed

2 files changed

+124
-121
lines changed

src/Renci.SshNet.Tests/Classes/SessionTest_Connected_ConnectionReset.cs

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,8 @@ public void ErrorOccurredIsRaisedOnce()
6464

6565
var connectionException = (SshConnectionException) exception;
6666
Assert.AreEqual(DisconnectReason.ConnectionLost, connectionException.DisconnectReason);
67-
68-
var innerException = exception.InnerException;
69-
Assert.IsNotNull(innerException);
70-
Assert.AreEqual(typeof(SocketException), innerException.GetType());
71-
72-
var socketException = (SocketException) innerException;
73-
Assert.AreSame(connectionException.Message, socketException.Message);
74-
Assert.AreEqual(SocketError.ConnectionReset, socketException.SocketErrorCode);
67+
Assert.IsNull(connectionException.InnerException);
68+
Assert.AreEqual("An established connection was aborted by the server.", connectionException.Message);
7569
}
7670

7771
[TestMethod]
@@ -140,7 +134,7 @@ public void ISession_TrySendMessageShouldReturnFalse()
140134
}
141135

142136
[TestMethod]
143-
public void ISession_WaitOnHandle_WaitHandle_ShouldThrowSshConnectionExceptionDetailingConnectionReset()
137+
public void ISession_WaitOnHandle_WaitHandle_ShouldThrowSshConnectionException()
144138
{
145139
var session = (ISession) Session;
146140
var waitHandle = new ManualResetEvent(false);
@@ -152,22 +146,14 @@ public void ISession_WaitOnHandle_WaitHandle_ShouldThrowSshConnectionExceptionDe
152146
}
153147
catch (SshConnectionException ex)
154148
{
149+
Assert.AreEqual("An established connection was aborted by the server.", ex.Message);
150+
Assert.IsNull(ex.InnerException);
155151
Assert.AreEqual(DisconnectReason.ConnectionLost, ex.DisconnectReason);
156-
157-
var innerException = ex.InnerException;
158-
Assert.IsNotNull(innerException);
159-
Assert.AreEqual(typeof(SocketException), innerException.GetType());
160-
161-
var socketException = (SocketException) ex.InnerException;
162-
Assert.IsNotNull(socketException);
163-
Assert.IsNull(socketException.InnerException);
164-
Assert.AreSame(innerException.Message, ex.Message);
165-
Assert.AreEqual(SocketError.ConnectionReset, socketException.SocketErrorCode);
166152
}
167153
}
168154

169155
[TestMethod]
170-
public void ISession_WaitOnHandle_WaitHandleAndTimeout_ShouldThrowSshConnectionExceptionDetailingConnectionReset()
156+
public void ISession_WaitOnHandle_WaitHandleAndTimeout_ShouldThrowSshConnectionException()
171157
{
172158
var session = (ISession) Session;
173159
var waitHandle = new ManualResetEvent(false);
@@ -180,16 +166,8 @@ public void ISession_WaitOnHandle_WaitHandleAndTimeout_ShouldThrowSshConnectionE
180166
catch (SshConnectionException ex)
181167
{
182168
Assert.AreEqual(DisconnectReason.ConnectionLost, ex.DisconnectReason);
183-
184-
var innerException = ex.InnerException;
185-
Assert.IsNotNull(innerException);
186-
Assert.AreEqual(typeof(SocketException), innerException.GetType());
187-
188-
var socketException = (SocketException) ex.InnerException;
189-
Assert.IsNotNull(socketException);
190-
Assert.IsNull(socketException.InnerException);
191-
Assert.AreSame(innerException.Message, socketException.Message);
192-
Assert.AreEqual(SocketError.ConnectionReset, socketException.SocketErrorCode);
169+
Assert.IsNull(ex.InnerException);
170+
Assert.AreEqual("An established connection was aborted by the server.", ex.Message);
193171
}
194172
}
195173

0 commit comments

Comments
 (0)