Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing old target frameworks #1109

Merged
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
855d57f
Just removing old target frameworks
WojciechNagorski Apr 11, 2023
d71147a
fix appveyor.yml
WojciechNagorski Apr 11, 2023
3122e18
Check ArgumentOutOfRangeException message
WojciechNagorski Apr 12, 2023
42111ad
Fix next tests
WojciechNagorski Apr 12, 2023
78369dc
Fix tests
WojciechNagorski Apr 12, 2023
abfd063
Fix SendMessageOnSessionShouldBeInvokedThreeTimes
WojciechNagorski Apr 12, 2023
56c0adc
Fix SessionTest_Connected tests
WojciechNagorski Apr 12, 2023
5231b73
Remove NET35
WojciechNagorski Apr 12, 2023
5af2256
Update AsyncSocketListener.cs
WojciechNagorski Apr 12, 2023
521b262
Update AsyncSocketListener.cs
WojciechNagorski Apr 12, 2023
1ef2fb4
Try to fix next random failed test
WojciechNagorski Apr 12, 2023
4abdf5d
Next try
WojciechNagorski Apr 12, 2023
0336a25
Add ObjectDisposedException again
WojciechNagorski Apr 12, 2023
0cc541f
improve tests for NETFRAMEWORK
WojciechNagorski Apr 12, 2023
b08eb41
catch ObjectDisposedException exceptions from SignalBytesReceived
WojciechNagorski Apr 12, 2023
1275707
SocketException (10058)
WojciechNagorski Apr 12, 2023
c4fe1cd
Try to fix test for .NET 7
WojciechNagorski Apr 13, 2023
e803d2b
Add blame
WojciechNagorski Apr 13, 2023
f2e15e2
Add more logs
WojciechNagorski Apr 13, 2023
419cc2a
ConnectionDisconnected
WojciechNagorski Apr 13, 2023
cecb0dd
Use Stopwatch
WojciechNagorski Apr 14, 2023
a8d0533
Show the value in CI/CD
WojciechNagorski Apr 14, 2023
7b2b39b
Update CountdownEventTest.cs
WojciechNagorski Apr 14, 2023
a9f5c1d
Update CountdownEventTest.cs
WojciechNagorski Apr 14, 2023
a6b8c7d
Add AfterAct
WojciechNagorski Apr 14, 2023
8c91779
Update CountdownEventTest.cs
WojciechNagorski Apr 14, 2023
79123fb
last fix?
WojciechNagorski Apr 14, 2023
899a8f8
Update ProtocolVersionExchangeTest_ServerResponseContainsNullCharacte…
WojciechNagorski Apr 14, 2023
bb0b78f
Fix @zybexXL review
WojciechNagorski Apr 14, 2023
5980570
Self review
WojciechNagorski Apr 17, 2023
fc277da
remove the unnecessary using statement
WojciechNagorski Apr 17, 2023
2242e1c
revert
WojciechNagorski Apr 17, 2023
8a5655f
Try
WojciechNagorski Apr 17, 2023
dba67ff
Revert "Try"
WojciechNagorski Apr 17, 2023
db06b60
Revert "revert"
WojciechNagorski Apr 17, 2023
8201be4
Revert "Self review"
WojciechNagorski Apr 17, 2023
3a4b62f
Fix review part 1
WojciechNagorski Apr 21, 2023
984c5c3
Undo accidental changes
WojciechNagorski Apr 21, 2023
af4eb4c
Update readme
WojciechNagorski Apr 24, 2023
7126f92
Use .NET 4.6.2
WojciechNagorski Apr 24, 2023
89079bd
Fix build scripts
WojciechNagorski Apr 24, 2023
35b42d6
Remove AfterAct
WojciechNagorski May 4, 2023
5e61359
Slow down .NET 6 tests
WojciechNagorski May 5, 2023
b23eda7
Fix review part 2
WojciechNagorski May 6, 2023
54a0509
Fix parameter order
WojciechNagorski May 6, 2023
2a5612b
Fix formatting
WojciechNagorski May 6, 2023
3d2ac9e
Remove paramName from MessageEquals
WojciechNagorski May 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
os: Visual Studio 2019
os: Visual Studio 2022

before_build:
- nuget restore src\Renci.SshNet.VS2019.sln
Expand All @@ -9,6 +9,6 @@ build:

test_script:
- cmd: >-
vstest.console /logger:Appveyor src\Renci.SshNet.Tests\bin\Debug\net35\Renci.SshNet.Tests.dll /TestCaseFilter:"TestCategory!=integration&TestCategory!=LongRunning"

vstest.console /logger:Appveyor src\Renci.SshNet.Tests\bin\Debug\net472\Renci.SshNet.Tests.dll /TestCaseFilter:"TestCategory!=integration&TestCategory!=LongRunning"
vstest.console /logger:Appveyor src\Renci.SshNet.Tests\bin\Debug\net472\Renci.SshNet.Tests.dll /TestCaseFilter:"TestCategory!=integration&TestCategory!=LongRunning" --blame
vstest.console /logger:Appveyor src\Renci.SshNet.Tests\bin\Debug\net7.0\Renci.SshNet.Tests.dll /TestCaseFilter:"TestCategory!=integration&TestCategory!=LongRunning" --blame
5 changes: 0 additions & 5 deletions src/Renci.SshNet.Silverlight/Properties/AssemblyInfo.cs

This file was deleted.

1,459 changes: 0 additions & 1,459 deletions src/Renci.SshNet.Silverlight/Renci.SshNet.Silverlight.csproj

This file was deleted.

4 changes: 0 additions & 4 deletions src/Renci.SshNet.Silverlight/packages.config

This file was deleted.

5 changes: 0 additions & 5 deletions src/Renci.SshNet.Silverlight5/Properties/AssemblyInfo.cs

This file was deleted.

1,463 changes: 0 additions & 1,463 deletions src/Renci.SshNet.Silverlight5/Renci.SshNet.Silverlight5.csproj

This file was deleted.

4 changes: 0 additions & 4 deletions src/Renci.SshNet.Silverlight5/packages.config

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ protected override void Act()
_client.KeepAliveInterval = _keepAliveInterval;

// allow keep-alive to be sent a few times
#if NETFRAMEWORK
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meaningful to have conditional compilation for this?

Copy link
Collaborator Author

@WojciechNagorski WojciechNagorski Apr 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I didn't have a better idea for this. We have the following test:

public void SendMessageOnSessionShouldBeInvokedThreeTimes()
{
_sessionMock.Verify(p => p.TrySendMessage(It.IsAny<IgnoreMessage>()), Times.Exactly(3));
}

Which checks if the message was sent three times, but .NET 7 has better performance and is able to send four messages in the same time. Any idea?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok for, perhaps just add a comment explaining why.

Thread.Sleep(195);
#else
Thread.Sleep(180);
#endif
}

[TestMethod]
Expand Down
4 changes: 2 additions & 2 deletions src/Renci.SshNet.Tests/Classes/ClientAuthenticationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void Ctor_PartialSuccessLimit_Zero()
catch (ArgumentOutOfRangeException ex)
{
Assert.IsNull(ex.InnerException);
Assert.AreEqual(string.Format("Cannot be less than one.{0}Parameter name: {1}", Environment.NewLine, ex.ParamName), ex.Message);
Assert.AreEqual(new ArgumentOutOfRangeException("partialSuccessLimit", "Cannot be less than one.").Message, ex.Message);
WojciechNagorski marked this conversation as resolved.
Show resolved Hide resolved
Assert.AreEqual("partialSuccessLimit", ex.ParamName);
}
}
Expand All @@ -46,7 +46,7 @@ public void Ctor_PartialSuccessLimit_Negative()
catch (ArgumentOutOfRangeException ex)
{
Assert.IsNull(ex.InnerException);
Assert.AreEqual(string.Format("Cannot be less than one.{0}Parameter name: {1}", Environment.NewLine, ex.ParamName), ex.Message);
Assert.AreEqual(new ArgumentOutOfRangeException("partialSuccessLimit", "Cannot be less than one.").Message, ex.Message);
WojciechNagorski marked this conversation as resolved.
Show resolved Hide resolved
Assert.AreEqual("partialSuccessLimit", ex.ParamName);
}
}
Expand Down
49 changes: 27 additions & 22 deletions src/Renci.SshNet.Tests/Classes/Common/CountdownEventTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
#if !FEATURE_THREAD_COUNTDOWNEVENT
Expand Down Expand Up @@ -111,16 +112,17 @@ public void Wait_TimeoutInfinite_ShouldBlockUntilCountdownEventIsSet()
threads[i].Start();
}

var start = DateTime.Now;
var watch = new Stopwatch();
watch.Start();
var actual = countdownEvent.Wait(timeout);
var elapsedTime = DateTime.Now - start;
watch.Stop();

Assert.IsTrue(actual);
Assert.AreEqual(expectedSignalCount, signalCount);
Assert.IsTrue(countdownEvent.IsSet);
Assert.IsTrue(countdownEvent.WaitHandle.WaitOne(0));
Assert.IsTrue(elapsedTime >= sleep);
Assert.IsTrue(elapsedTime <= sleep.Add(TimeSpan.FromMilliseconds(100)));
Assert.IsTrue(watch.Elapsed >= sleep);
Assert.IsTrue(watch.Elapsed <= sleep.Add(TimeSpan.FromMilliseconds(100)));

countdownEvent.Dispose();
}
Expand Down Expand Up @@ -150,16 +152,17 @@ public void Wait_ShouldReturnTrueWhenCountdownEventIsSetBeforeTimeoutExpires()
threads[i].Start();
}

var start = DateTime.Now;
var watch = new Stopwatch();
watch.Start();
var actual = countdownEvent.Wait(timeout);
var elapsedTime = DateTime.Now - start;
watch.Stop();

Assert.IsTrue(actual);
Assert.AreEqual(expectedSignalCount, signalCount);
Assert.IsTrue(countdownEvent.IsSet);
Assert.IsTrue(countdownEvent.WaitHandle.WaitOne(0));
Assert.IsTrue(elapsedTime >= sleep);
Assert.IsTrue(elapsedTime <= timeout);
Assert.IsTrue(watch.Elapsed >= sleep);
Assert.IsTrue(watch.Elapsed <= timeout);

countdownEvent.Dispose();
}
Expand Down Expand Up @@ -189,14 +192,14 @@ public void Wait_ShouldReturnFalseWhenTimeoutExpiresBeforeCountdownEventIsSet()
threads[i].Start();
}

var start = DateTime.Now;
var watch = new Stopwatch();
watch.Start();
var actual = countdownEvent.Wait(timeout);
var elapsedTime = DateTime.Now - start;
watch.Stop();

Assert.IsFalse(actual);
Assert.IsFalse(countdownEvent.IsSet);
Assert.IsFalse(countdownEvent.WaitHandle.WaitOne(0));
Assert.IsTrue(elapsedTime >= timeout);

countdownEvent.Wait(Session.InfiniteTimeSpan);
countdownEvent.Dispose();
Expand Down Expand Up @@ -239,16 +242,17 @@ public void WaitHandle_WaitOne_TimeoutInfinite_ShouldBlockUntilCountdownEventIsS
threads[i].Start();
}

var start = DateTime.Now;
var watch = new Stopwatch();
watch.Start();
var actual = countdownEvent.WaitHandle.WaitOne(timeout);
var elapsedTime = DateTime.Now - start;
watch.Stop();

Assert.IsTrue(actual);
Assert.AreEqual(expectedSignalCount, signalCount);
Assert.IsTrue(countdownEvent.IsSet);
Assert.IsTrue(countdownEvent.WaitHandle.WaitOne(0));
Assert.IsTrue(elapsedTime >= sleep);
Assert.IsTrue(elapsedTime <= sleep.Add(TimeSpan.FromMilliseconds(100)));
Assert.IsTrue(watch.Elapsed >= sleep);
Assert.IsTrue(watch.Elapsed <= sleep.Add(TimeSpan.FromMilliseconds(100)));

countdownEvent.Dispose();
}
Expand Down Expand Up @@ -278,16 +282,17 @@ public void WaitHandle_WaitOne_ShouldReturnTrueWhenCountdownEventIsSetBeforeTime
threads[i].Start();
}

var start = DateTime.Now;
var watch = new Stopwatch();
watch.Start();
var actual = countdownEvent.Wait(timeout);
var elapsedTime = DateTime.Now - start;
watch.Stop();

Assert.IsTrue(actual);
Assert.AreEqual(expectedSignalCount, signalCount);
Assert.IsTrue(countdownEvent.IsSet);
Assert.IsTrue(countdownEvent.WaitHandle.WaitOne(0));
Assert.IsTrue(elapsedTime >= sleep);
Assert.IsTrue(elapsedTime <= timeout);
Assert.IsTrue(watch.Elapsed >= sleep);
Assert.IsTrue(watch.Elapsed <= timeout);

countdownEvent.Dispose();
}
Expand Down Expand Up @@ -317,14 +322,14 @@ public void WaitHandle_WaitOne_ShouldReturnFalseWhenTimeoutExpiresBeforeCountdow
threads[i].Start();
}

var start = DateTime.Now;
var watch = new Stopwatch();
watch.Start();
var actual = countdownEvent.WaitHandle.WaitOne(timeout);
var elapsedTime = DateTime.Now - start;
watch.Stop();

Assert.IsFalse(actual);
Assert.IsFalse(countdownEvent.IsSet);
Assert.IsFalse(countdownEvent.WaitHandle.WaitOne(0));
Assert.IsTrue(elapsedTime >= timeout);

countdownEvent.Wait(Session.InfiniteTimeSpan);
countdownEvent.Dispose();
Expand Down
8 changes: 3 additions & 5 deletions src/Renci.SshNet.Tests/Classes/Common/PacketDumpTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ public void Create_ByteArrayAndIndentLevel_IndentLevelLessThanZero()
catch (ArgumentOutOfRangeException ex)
{
Assert.IsNull(ex.InnerException);
#if NETFRAMEWORK
Assert.AreEqual(string.Format("Cannot be less than zero.{0}Parameter name: {1}", Environment.NewLine, ex.ParamName), ex.Message);
#else
Assert.AreEqual(string.Format("Cannot be less than zero. (Parameter '{1}')", Environment.NewLine, ex.ParamName), ex.Message);
#endif

Assert.AreEqual(new ArgumentOutOfRangeException("indentLevel", "Cannot be less than zero.").Message, ex.Message);
WojciechNagorski marked this conversation as resolved.
Show resolved Hide resolved

Assert.AreEqual("indentLevel", ex.ParamName);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ protected override void Arrange()
catch (Exception ex)
{
_writeException = ex;
throw;
}
});
_writehread.Start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void ReadingMoreBytesThanAvailableDoesNotBlock()
Assert.AreEqual(0, buffer[2]);
Assert.AreEqual(0, buffer[3]);
}

#if NETFRAMEWORK
[TestMethod]
public void WriteCausesSubsequentReadToBlockUntilRequestedNumberOfBytesAreAvailable()
{
Expand All @@ -104,13 +104,17 @@ public void WriteCausesSubsequentReadToBlockUntilRequestedNumberOfBytesAreAvaila
readThread.Start();

Assert.IsFalse(readThread.Join(500));

// Thread Abort method is obsolete: https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/5.0/thread-abort-obsolete
readThread.Abort();


Assert.AreEqual(int.MaxValue, bytesRead);
Assert.AreEqual(0, buffer[0]);
Assert.AreEqual(0, buffer[1]);
Assert.AreEqual(0, buffer[2]);
Assert.AreEqual(0, buffer[3]);
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void Path_Empty()
catch (ArgumentException ex)
{
Assert.IsNull(ex.InnerException);
Assert.AreEqual(string.Format("The path is a zero-length string.{0}Parameter name: {1}", Environment.NewLine, ex.ParamName), ex.Message);
Assert.AreEqual(new ArgumentException("The path is a zero-length string.", "path").Message, ex.Message);
WojciechNagorski marked this conversation as resolved.
Show resolved Hide resolved
Assert.AreEqual("path", ex.ParamName);
}
}
Expand Down
15 changes: 8 additions & 7 deletions src/Renci.SshNet.Tests/Classes/Common/SemaphoreLightTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Renci.SshNet.Common;
Expand Down Expand Up @@ -58,12 +59,13 @@ public void WaitTest()
const int initialCount = 2;
var target = new SemaphoreLight(initialCount);

var start = DateTime.Now;
var watch = new Stopwatch();
watch.Start();

target.Wait();
target.Wait();

Assert.IsTrue((DateTime.Now - start).TotalMilliseconds < 50);
Assert.IsTrue(watch.ElapsedMilliseconds < 50);

var releaseThread = new Thread(
() =>
Expand All @@ -75,11 +77,10 @@ public void WaitTest()

target.Wait();

var end = DateTime.Now;
var elapsed = end - start;
watch.Stop();

Assert.IsTrue(elapsed.TotalMilliseconds > 200);
Assert.IsTrue(elapsed.TotalMilliseconds < 250);
Assert.IsTrue(watch.ElapsedMilliseconds > 200);
Assert.IsTrue(watch.ElapsedMilliseconds < 250);
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Moq;
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
using System.Threading;

namespace Renci.SshNet.Tests.Classes.Connection
{
Expand All @@ -25,6 +26,12 @@ protected virtual void SetupMocks()
{
}

protected override void AfterAct()
{
// Give some time to process all messages
Thread.Sleep(400);
}

protected sealed override void Arrange()
{
CreateMocks();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;

namespace Renci.SshNet.Tests.Classes.Connection
{
Expand Down Expand Up @@ -83,6 +84,9 @@ protected void Act()
{
_actualException = ex;
}

// Give some time to process all messages
Thread.Sleep(200);
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Renci.SshNet.Connection;
using Renci.SshNet.Tests.Common;
using System.Net;
using System.Threading;

namespace Renci.SshNet.Tests.Classes.Connection
{
Expand Down Expand Up @@ -33,6 +34,12 @@ protected sealed override void Arrange()
SetupMocks();
}

protected override void AfterAct()
{
// Give some time to process all messages
Thread.Sleep(200);
}

protected ConnectionInfo CreateConnectionInfo(string proxyUser, string proxyPassword)
{
return new ConnectionInfo(IPAddress.Loopback.ToString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Net;
using System.Text;
using System.Threading;

namespace Renci.SshNet.Tests.Classes.Connection
{
Expand Down Expand Up @@ -35,6 +36,12 @@ protected sealed override void Arrange()
SetupMocks();
}

protected override void AfterAct()
{
// Give some time to process all messages
Thread.Sleep(200);
}

protected ConnectionInfo CreateConnectionInfo(string proxyUser, string proxyPassword)
{
return new ConnectionInfo(IPAddress.Loopback.ToString(),
Expand Down
4 changes: 2 additions & 2 deletions src/Renci.SshNet.Tests/Classes/NetConfClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void OperationTimeout_LessThanLowerLimit()
catch (ArgumentOutOfRangeException ex)
{
Assert.IsNull(ex.InnerException);
Assert.AreEqual("The timeout must represent a value between -1 and Int32.MaxValue, inclusive." + Environment.NewLine + "Parameter name: " + ex.ParamName, ex.Message);
Assert.AreEqual(new ArgumentOutOfRangeException("value", "The timeout must represent a value between -1 and Int32.MaxValue, inclusive.").Message, ex.Message);
WojciechNagorski marked this conversation as resolved.
Show resolved Hide resolved
Assert.AreEqual("value", ex.ParamName);
}
}
Expand All @@ -105,7 +105,7 @@ public void OperationTimeout_GreaterThanLowerLimit()
catch (ArgumentOutOfRangeException ex)
{
Assert.IsNull(ex.InnerException);
Assert.AreEqual("The timeout must represent a value between -1 and Int32.MaxValue, inclusive." + Environment.NewLine + "Parameter name: " + ex.ParamName, ex.Message);
Assert.AreEqual(new ArgumentOutOfRangeException("value", "The timeout must represent a value between -1 and Int32.MaxValue, inclusive.").Message, ex.Message);
WojciechNagorski marked this conversation as resolved.
Show resolved Hide resolved
Assert.AreEqual("value", ex.ParamName);
}
}
Expand Down
Loading