diff --git a/Build/build.ps1 b/Build/build.ps1
index 33f2767..57a60f6 100644
--- a/Build/build.ps1
+++ b/Build/build.ps1
@@ -43,8 +43,14 @@ Write-Host
&$msbuild ..\Source\MQTTnet.Extensions.WebSocket4Net\MQTTnet.Extensions.WebSocket4Net.csproj /t:Build /p:Configuration="Release" /p:TargetFramework="netstandard2.0" /p:FileVersion=$assemblyVersion /p:AssemblyVersion=$assemblyVersion /verbosity:m /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=".\..\..\Build\codeSigningKey.pfx"
&$msbuild ..\Source\MQTTnet.Extensions.WebSocket4Net\MQTTnet.Extensions.WebSocket4Net.csproj /t:Build /p:Configuration="Release" /p:TargetFramework="uap10.0" /p:FileVersion=$assemblyVersion /p:AssemblyVersion=$assemblyVersion /verbosity:m /p:SignAssembly=true /p:AssemblyOriginatorKeyFile=".\..\..\Build\codeSigningKey.pfx"
-# Create NuGet packages.
+# Build and execute tests
+&$msbuild ..\Tests\MQTTnet.Core.Tests\MQTTnet.Tests.csproj /t:Build /p:Configuration="Release" /p:TargetFramework="netcoreapp2.1" /verbosity:m
+&$msbuild ..\Tests\MQTTnet.AspNetCore.Tests\MQTTnet.AspNetCore.Tests.csproj /t:Build /p:Configuration="Release" /p:TargetFramework="netcoreapp2.1" /verbosity:m
+
+vstest.console.exe ..\Tests\MQTTnet.Core.Tests\bin\Release\netcoreapp2.1\MQTTnet.Tests.dll
+vstest.console.exe ..\Tests\MQTTnet.AspNetCore.Tests\bin\Release\netcoreapp2.1\MQTTnet.AspNetCore.Tests.dll
+# Create NuGet packages.
Invoke-WebRequest -Uri "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile "nuget.exe"
Remove-Item .\NuGet -Force -Recurse -ErrorAction SilentlyContinue
diff --git a/Tests/MQTTnet.AspNetCore.Tests/MQTTnet.AspNetCore.Tests.csproj b/Tests/MQTTnet.AspNetCore.Tests/MQTTnet.AspNetCore.Tests.csproj
index a756dd1..4569af3 100644
--- a/Tests/MQTTnet.AspNetCore.Tests/MQTTnet.AspNetCore.Tests.csproj
+++ b/Tests/MQTTnet.AspNetCore.Tests/MQTTnet.AspNetCore.Tests.csproj
@@ -2,7 +2,6 @@
netcoreapp2.1
-
false
diff --git a/Tests/MQTTnet.Core.Tests/MQTTnet.Tests.csproj b/Tests/MQTTnet.Core.Tests/MQTTnet.Tests.csproj
index 63bd0de..830051d 100644
--- a/Tests/MQTTnet.Core.Tests/MQTTnet.Tests.csproj
+++ b/Tests/MQTTnet.Core.Tests/MQTTnet.Tests.csproj
@@ -1,9 +1,8 @@
- Exe
- Full
netcoreapp2.1
+ false
diff --git a/Tests/MQTTnet.Core.Tests/MqttKeepAliveMonitor_Tests.cs b/Tests/MQTTnet.Core.Tests/MqttKeepAliveMonitor_Tests.cs
index adf9a2b..fe1a0c5 100644
--- a/Tests/MQTTnet.Core.Tests/MqttKeepAliveMonitor_Tests.cs
+++ b/Tests/MQTTnet.Core.Tests/MqttKeepAliveMonitor_Tests.cs
@@ -14,7 +14,7 @@ namespace MQTTnet.Tests
public class MqttKeepAliveMonitor_Tests
{
[TestMethod]
- public void KeepAlive_Timeout()
+ public async Task KeepAlive_Timeout()
{
var counter = 0;
@@ -31,13 +31,13 @@ namespace MQTTnet.Tests
Assert.AreEqual(0, counter);
- Thread.Sleep(2000); // Internally the keep alive timeout is multiplied with 1.5 as per protocol specification.
+ await Task.Delay(2000); // Internally the keep alive timeout is multiplied with 1.5 as per protocol specification.
Assert.AreEqual(1, counter);
}
[TestMethod]
- public void KeepAlive_NoTimeout()
+ public async Task KeepAlive_NoTimeout()
{
var counter = 0;
@@ -55,15 +55,15 @@ namespace MQTTnet.Tests
Assert.AreEqual(0, counter);
// Simulate traffic.
- Thread.Sleep(1000); // Internally the keep alive timeout is multiplied with 1.5 as per protocol specification.
+ await Task.Delay(1000); // Internally the keep alive timeout is multiplied with 1.5 as per protocol specification.
monitor.PacketReceived();
- Thread.Sleep(1000);
+ await Task.Delay(1000);
monitor.PacketReceived();
- Thread.Sleep(1000);
+ await Task.Delay(1000);
Assert.AreEqual(0, counter);
- Thread.Sleep(2000);
+ await Task.Delay(2000);
Assert.AreEqual(1, counter);
}
diff --git a/Tests/MQTTnet.Core.Tests/Server_Tests.cs b/Tests/MQTTnet.Core.Tests/Server_Tests.cs
index d10ebaf..b2b3b70 100644
--- a/Tests/MQTTnet.Core.Tests/Server_Tests.cs
+++ b/Tests/MQTTnet.Core.Tests/Server_Tests.cs
@@ -1063,7 +1063,9 @@ namespace MQTTnet.Tests
// forever. This is security related.
var client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
await client.ConnectAsync("localhost", testEnvironment.ServerPort);
- await client.SendAsync(Encoding.UTF8.GetBytes("Garbage"), SocketFlags.None);
+
+ var buffer = Encoding.UTF8.GetBytes("Garbage");
+ client.Send(buffer, buffer.Length, SocketFlags.None);
await Task.Delay(TimeSpan.FromSeconds(3));