Fix some test failures on .NET Core.

This commit is contained in:
drieseng
2020-12-30 15:13:57 +01:00
parent d5fefcc369
commit a5148aea1a
7 changed files with 71 additions and 39 deletions
@@ -55,6 +55,10 @@ namespace Renci.SshNet.Tests.Classes
.Returns(false);
_channelSessionMock.InSequence(sequence).Setup(p => p.Dispose());
_pipeStreamMock.As<IDisposable>().InSequence(sequence).Setup(p => p.Dispose());
// On .NET Core, Dispose() in turn invokes Close() and since we're not mocking
// an interface, we need to expect this call as well
_pipeStreamMock.Setup(p => p.Close());
}
protected override void Arrange()
@@ -54,6 +54,10 @@ namespace Renci.SshNet.Tests.Classes
.Setup(p => p.SendExecRequest(string.Format("scp -pf {0}", _transformedPath))).Returns(false);
_channelSessionMock.InSequence(sequence).Setup(p => p.Dispose());
_pipeStreamMock.As<IDisposable>().InSequence(sequence).Setup(p => p.Dispose());
// On .NET Core, Dispose() in turn invokes Close() and since we're not mocking
// an interface, we need to expect this call as well
_pipeStreamMock.Setup(p => p.Close());
}
protected override void Arrange()
@@ -19,15 +19,6 @@ namespace Renci.SshNet.Tests.Classes
private IList<ScpUploadEventArgs> _uploadingRegister;
private SshException _actualException;
[TestCleanup]
public void Cleanup()
{
if (_destination != null)
{
_destination.Dispose();
}
}
protected override void SetupData()
{
var random = new Random();
@@ -64,6 +55,10 @@ namespace Renci.SshNet.Tests.Classes
.Returns(false);
_channelSessionMock.InSequence(sequence).Setup(p => p.Dispose());
_pipeStreamMock.As<IDisposable>().InSequence(sequence).Setup(p => p.Dispose());
// On .NET Core, Dispose() in turn invokes Close() and since we're not mocking
// an interface, we need to expect this call as well
_pipeStreamMock.Setup(p => p.Close());
}
protected override void Arrange()
@@ -75,6 +70,16 @@ namespace Renci.SshNet.Tests.Classes
_scpClient.Connect();
}
protected override void TearDown()
{
base.TearDown();
if (_destination != null)
{
_destination.Dispose();
}
}
protected override void Act()
{
try
@@ -54,6 +54,10 @@ namespace Renci.SshNet.Tests.Classes
.Returns(false);
_channelSessionMock.InSequence(sequence).Setup(p => p.Dispose());
_pipeStreamMock.As<IDisposable>().InSequence(sequence).Setup(p => p.Dispose());
// On .NET Core, Dispose() in turn invokes Close() and since we're not mocking
// an interface, we need to expect this call as well
_pipeStreamMock.Setup(p => p.Close());
}
protected override void Arrange()
@@ -21,16 +21,6 @@ namespace Renci.SshNet.Tests.Classes
private IList<ScpUploadEventArgs> _uploadingRegister;
private SshException _actualException;
[TestCleanup]
public void Cleanup()
{
if (_fileName != null)
{
File.Delete(_fileName);
_fileName = null;
}
}
protected override void SetupData()
{
var random = new Random();
@@ -70,7 +60,11 @@ namespace Renci.SshNet.Tests.Classes
.Returns(false);
_channelSessionMock.InSequence(sequence).Setup(p => p.Dispose());
_pipeStreamMock.As<IDisposable>().InSequence(sequence).Setup(p => p.Dispose());
}
// On .NET Core, Dispose() in turn invokes Close() and since we're not mocking
// an interface, we need to expect this call as well
_pipeStreamMock.Setup(p => p.Close());
}
protected override void Arrange()
{
@@ -81,6 +75,17 @@ namespace Renci.SshNet.Tests.Classes
_scpClient.Connect();
}
protected override void TearDown()
{
base.TearDown();
if (_fileName != null)
{
File.Delete(_fileName);
_fileName = null;
}
}
protected override void Act()
{
try
@@ -25,16 +25,6 @@ namespace Renci.SshNet.Tests.Classes
private int _fileSize;
private IList<ScpUploadEventArgs> _uploadingRegister;
[TestCleanup]
public void Cleanup()
{
if (_fileName != null)
{
File.Delete(_fileName);
_fileName = null;
}
}
protected override void SetupData()
{
var random = new Random();
@@ -95,6 +85,10 @@ namespace Renci.SshNet.Tests.Classes
_pipeStreamMock.InSequence(sequence).Setup(p => p.ReadByte()).Returns(0);
_channelSessionMock.InSequence(sequence).Setup(p => p.Dispose());
_pipeStreamMock.As<IDisposable>().InSequence(sequence).Setup(p => p.Dispose());
// On .NET Core, Dispose() in turn invokes Close() and since we're not mocking
// an interface, we need to expect this call as well
_pipeStreamMock.Setup(p => p.Close());
}
protected override void Arrange()
@@ -109,6 +103,17 @@ namespace Renci.SshNet.Tests.Classes
_scpClient.Connect();
}
protected override void TearDown()
{
base.TearDown();
if (_fileName != null)
{
File.Delete(_fileName);
_fileName = null;
}
}
protected override void Act()
{
_scpClient.Upload(_fileInfo, _remotePath);
@@ -20,15 +20,6 @@ namespace Renci.SshNet.Tests.Classes
private IList<ScpUploadEventArgs> _uploadingRegister;
private SshException _actualException;
[TestCleanup]
public void Cleanup()
{
if (_source != null)
{
_source.Dispose();
}
}
protected override void SetupData()
{
var random = new Random();
@@ -67,6 +58,10 @@ namespace Renci.SshNet.Tests.Classes
.Returns(false);
_channelSessionMock.InSequence(sequence).Setup(p => p.Dispose());
_pipeStreamMock.As<IDisposable>().InSequence(sequence).Setup(p => p.Dispose());
// On .NET Core, Dispose() in turn invokes Close() and since we're not mocking
// an interface, we need to expect this call as well
_pipeStreamMock.Setup(p => p.Close());
}
protected override void Arrange()
@@ -78,6 +73,16 @@ namespace Renci.SshNet.Tests.Classes
_scpClient.Connect();
}
protected override void TearDown()
{
base.TearDown();
if (_source != null)
{
_source.Dispose();
}
}
protected override void Act()
{
try