浏览代码

Refactoring

release/3.x.x
Christian Kratky 6 年前
父节点
当前提交
3480d9ac35
共有 17 个文件被更改,包括 88 次插入19 次删除
  1. +22
    -0
      MQTTnet.sln
  2. +1
    -1
      README.md
  3. +0
    -1
      Tests/MQTTnet.Benchmarks/ChannelAdapterBenchmark.cs
  4. +1
    -2
      Tests/MQTTnet.Benchmarks/SerializerBenchmark.cs
  5. +1
    -3
      Tests/MQTTnet.Benchmarks/Tcp/BufferExtensions.cs
  6. +1
    -3
      Tests/MQTTnet.Benchmarks/Tcp/SocketAwaitable.cs
  7. +0
    -1
      Tests/MQTTnet.Benchmarks/Tcp/SocketReceiver.cs
  8. +0
    -1
      Tests/MQTTnet.Benchmarks/Tcp/SocketSender.cs
  9. +0
    -1
      Tests/MQTTnet.Benchmarks/Tcp/TcpConnection.cs
  10. +1
    -1
      Tests/MQTTnet.Core.Tests/MqttPacketReaderTests.cs
  11. +2
    -2
      Tests/MQTTnet.Core.Tests/MqttPacketSerializerTests.cs
  12. +47
    -0
      Tests/MQTTnet.TestApp.NetCore/ClientFlowTest.cs
  13. +1
    -0
      Tests/MQTTnet.TestApp.NetCore/MQTTnet.TestApp.NetCore.csproj
  14. +1
    -1
      Tests/MQTTnet.TestApp.NetCore/ManagedClientTest.cs
  15. +5
    -0
      Tests/MQTTnet.TestApp.NetCore/Program.cs
  16. +4
    -0
      Tests/MQTTnet.TestApp.UniversalWindows/MQTTnet.TestApp.UniversalWindows.csproj
  17. +1
    -2
      Tests/MQTTnet.TestApp.UniversalWindows/MainPage.xaml.cs

+ 22
- 0
MQTTnet.sln 查看文件

@@ -18,12 +18,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{67C28AC1
appveyor.yml = appveyor.yml
Build\build.ps1 = Build\build.ps1
Build\MQTTnet.AspNetCore.nuspec = Build\MQTTnet.AspNetCore.nuspec
Build\MQTTnet.Extensions.ManagedClient.nuspec = Build\MQTTnet.Extensions.ManagedClient.nuspec
Build\MQTTnet.Extensions.Rpc.nuspec = Build\MQTTnet.Extensions.Rpc.nuspec
Build\MQTTnet.nuspec = Build\MQTTnet.nuspec
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B3F60ECB-45BA-4C66-8903-8BB89CA67998}"
ProjectSection(SolutionItems) = preProject
.bettercodehub.yml = .bettercodehub.yml
appveyor.yml = appveyor.yml
LICENSE = LICENSE
README.md = README.md
EndProjectSection
@@ -40,6 +43,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MQTTnet.Extensions.Rpc", "E
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MQTTnet.Benchmarks", "Tests\MQTTnet.Benchmarks\MQTTnet.Benchmarks.csproj", "{998D04DD-7CB0-45F5-A393-E2495C16399E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MQTTnet.Extensions.ManagedClient", "Extensions\MQTTnet.Extensions.ManagedClient\MQTTnet.Extensions.ManagedClient.csproj", "{C400533A-8EBA-4F0B-BF4D-295C3708604B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -186,6 +191,22 @@ Global
{998D04DD-7CB0-45F5-A393-E2495C16399E}.Release|x64.Build.0 = Release|Any CPU
{998D04DD-7CB0-45F5-A393-E2495C16399E}.Release|x86.ActiveCfg = Release|Any CPU
{998D04DD-7CB0-45F5-A393-E2495C16399E}.Release|x86.Build.0 = Release|Any CPU
{C400533A-8EBA-4F0B-BF4D-295C3708604B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C400533A-8EBA-4F0B-BF4D-295C3708604B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C400533A-8EBA-4F0B-BF4D-295C3708604B}.Debug|ARM.ActiveCfg = Debug|Any CPU
{C400533A-8EBA-4F0B-BF4D-295C3708604B}.Debug|ARM.Build.0 = Debug|Any CPU
{C400533A-8EBA-4F0B-BF4D-295C3708604B}.Debug|x64.ActiveCfg = Debug|Any CPU
{C400533A-8EBA-4F0B-BF4D-295C3708604B}.Debug|x64.Build.0 = Debug|Any CPU
{C400533A-8EBA-4F0B-BF4D-295C3708604B}.Debug|x86.ActiveCfg = Debug|Any CPU
{C400533A-8EBA-4F0B-BF4D-295C3708604B}.Debug|x86.Build.0 = Debug|Any CPU
{C400533A-8EBA-4F0B-BF4D-295C3708604B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C400533A-8EBA-4F0B-BF4D-295C3708604B}.Release|Any CPU.Build.0 = Release|Any CPU
{C400533A-8EBA-4F0B-BF4D-295C3708604B}.Release|ARM.ActiveCfg = Release|Any CPU
{C400533A-8EBA-4F0B-BF4D-295C3708604B}.Release|ARM.Build.0 = Release|Any CPU
{C400533A-8EBA-4F0B-BF4D-295C3708604B}.Release|x64.ActiveCfg = Release|Any CPU
{C400533A-8EBA-4F0B-BF4D-295C3708604B}.Release|x64.Build.0 = Release|Any CPU
{C400533A-8EBA-4F0B-BF4D-295C3708604B}.Release|x86.ActiveCfg = Release|Any CPU
{C400533A-8EBA-4F0B-BF4D-295C3708604B}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -199,6 +220,7 @@ Global
{F10C4060-F7EE-4A83-919F-FF723E72F94A} = {32A630A7-2598-41D7-B625-204CD906F5FB}
{C444E9C8-95FA-430E-9126-274129DE16CD} = {12816BCC-AF9E-44A9-9AE5-C246AF2A0587}
{998D04DD-7CB0-45F5-A393-E2495C16399E} = {9248C2E1-B9D6-40BF-81EC-86004D7765B4}
{C400533A-8EBA-4F0B-BF4D-295C3708604B} = {12816BCC-AF9E-44A9-9AE5-C246AF2A0587}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {07536672-5CBC-4BE3-ACE0-708A431A7894}


+ 1
- 1
README.md 查看文件

@@ -21,7 +21,7 @@ MQTTnet is a high performance .NET library for MQTT based communication. It prov
* Performance optimized (processing ~60.000 messages / second)*
* Interfaces included for mocking and testing
* Access to internal trace messages
* Unit tested (~80 tests)
* Unit tested (~90 tests)

\* Tested on local machine (Intel i7 8700K) with MQTTnet client and server running in the same process using the TCP channel. The app for verification is part of this repository and stored in _/Tests/MQTTnet.TestApp.NetCore_.



+ 0
- 1
Tests/MQTTnet.Benchmarks/ChannelAdapterBenchmark.cs 查看文件

@@ -1,6 +1,5 @@
using BenchmarkDotNet.Attributes;
using MQTTnet.Adapter;
using MQTTnet.Core.Internal;
using MQTTnet.Diagnostics;
using MQTTnet.Internal;
using MQTTnet.Packets;


+ 1
- 2
Tests/MQTTnet.Benchmarks/SerializerBenchmark.cs 查看文件

@@ -8,7 +8,6 @@ using System;
using System.Threading;
using System.IO;
using MQTTnet.Adapter;
using MQTTnet.Core.Internal;

namespace MQTTnet.Benchmarks
{
@@ -55,7 +54,7 @@ namespace MQTTnet.Benchmarks
using (var bodyStream = new MemoryStream(Join(_serializedPacket), (int)headerStream.Position, header.RemainingLength))
{
_serializer.Deserialize(new ReceivedMqttPacket(header.Flags, bodyStream));
_serializer.Deserialize(new ReceivedMqttPacket(header.Flags, new MqttPacketBodyReader(bodyStream.ToArray())));
}
}
}


+ 1
- 3
Tests/MQTTnet.Benchmarks/Tcp/BufferExtensions.cs 查看文件

@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

namespace Playground.Client.Mqtt.Tcp
namespace MQTTnet.Benchmarks.Tcp
{
public static class BufferExtensions
{


+ 1
- 3
Tests/MQTTnet.Benchmarks/Tcp/SocketAwaitable.cs 查看文件

@@ -1,14 +1,12 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO.Pipelines;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Playground.Client.Mqtt.Tcp
namespace MQTTnet.Benchmarks.Tcp
{
public class SocketAwaitable : ICriticalNotifyCompletion
{


+ 0
- 1
Tests/MQTTnet.Benchmarks/Tcp/SocketReceiver.cs 查看文件

@@ -1,7 +1,6 @@
using System;
using System.IO.Pipelines;
using System.Net.Sockets;
using Playground.Client.Mqtt.Tcp;

namespace MQTTnet.Benchmarks.Tcp
{


+ 0
- 1
Tests/MQTTnet.Benchmarks/Tcp/SocketSender.cs 查看文件

@@ -4,7 +4,6 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO.Pipelines;
using System.Net.Sockets;
using Playground.Client.Mqtt.Tcp;

namespace MQTTnet.Benchmarks.Tcp
{


+ 0
- 1
Tests/MQTTnet.Benchmarks/Tcp/TcpConnection.cs 查看文件

@@ -6,7 +6,6 @@ using System.Net;
using System.Net.Sockets;
using System.Threading.Tasks;
using MQTTnet.Exceptions;
using Playground.Client.Mqtt.Tcp;

namespace MQTTnet.Benchmarks.Tcp
{


+ 1
- 1
Tests/MQTTnet.Core.Tests/MqttPacketReaderTests.cs 查看文件

@@ -1,8 +1,8 @@
using System.IO;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MQTTnet.Core.Internal;
using MQTTnet.Exceptions;
using MQTTnet.Internal;
using MQTTnet.Serializer;

namespace MQTTnet.Core.Tests


+ 2
- 2
Tests/MQTTnet.Core.Tests/MqttPacketSerializerTests.cs 查看文件

@@ -4,7 +4,7 @@ using System.Text;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MQTTnet.Adapter;
using MQTTnet.Core.Internal;
using MQTTnet.Internal;
using MQTTnet.Packets;
using MQTTnet.Protocol;
using MQTTnet.Serializer;
@@ -422,7 +422,7 @@ namespace MQTTnet.Core.Tests
using (var bodyStream = new MemoryStream(Join(buffer1), (int)headerStream.Position, header.RemainingLength))
{
var deserializedPacket = serializer.Deserialize(new ReceivedMqttPacket(header.Flags, bodyStream));
var deserializedPacket = serializer.Deserialize(new ReceivedMqttPacket(header.Flags, new MqttPacketBodyReader(bodyStream.ToArray())));
var buffer2 = serializer.Serialize(deserializedPacket);

Assert.AreEqual(expectedBase64Value, Convert.ToBase64String(Join(buffer2)));


+ 47
- 0
Tests/MQTTnet.TestApp.NetCore/ClientFlowTest.cs 查看文件

@@ -0,0 +1,47 @@
using System;
using System.Threading.Tasks;
using MQTTnet.Client;

namespace MQTTnet.TestApp.NetCore
{
public static class ClientFlowTest
{
public static async Task RunAsync()
{
MqttNetConsoleLogger.ForwardToConsole();
try
{
var factory = new MqttFactory();
var client = factory.CreateMqttClient();
var options = new MqttClientOptionsBuilder()
.WithTcpServer("localhost")
.Build();
Console.WriteLine("BEFORE CONNECT");
await client.ConnectAsync(options);
Console.WriteLine("AFTER CONNECT");

Console.WriteLine("BEFORE SUBSCRIBE");
await client.SubscribeAsync("test/topic");
Console.WriteLine("AFTER SUBSCRIBE");

Console.WriteLine("BEFORE PUBLISH");
await client.PublishAsync("test/topic", "payload");
Console.WriteLine("AFTER PUBLISH");

await Task.Delay(1000);

Console.WriteLine("BEFORE DISCONNECT");
await client.DisconnectAsync();
Console.WriteLine("AFTER DISCONNECT");

Console.WriteLine("FINISHED");
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
}

+ 1
- 0
Tests/MQTTnet.TestApp.NetCore/MQTTnet.TestApp.NetCore.csproj 查看文件

@@ -15,6 +15,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Extensions\MQTTnet.Extensions.ManagedClient\MQTTnet.Extensions.ManagedClient.csproj" />
<ProjectReference Include="..\..\Frameworks\MQTTnet.NetStandard\MQTTnet.NetStandard.csproj" />
</ItemGroup>



+ 1
- 1
Tests/MQTTnet.TestApp.NetCore/ManagedClientTest.cs 查看文件

@@ -4,7 +4,7 @@ using System.IO;
using Newtonsoft.Json;
using System.Collections.Generic;
using MQTTnet.Client;
using MQTTnet.ManagedClient;
using MQTTnet.Extensions.ManagedClient;
using MQTTnet.Protocol;

namespace MQTTnet.TestApp.NetCore


+ 5
- 0
Tests/MQTTnet.TestApp.NetCore/Program.cs 查看文件

@@ -21,6 +21,7 @@ namespace MQTTnet.TestApp.NetCore
Console.WriteLine("4 = Start managed client");
Console.WriteLine("5 = Start public broker test");
Console.WriteLine("6 = Start server & client");
Console.WriteLine("7 = Client flow test");

var pressedKey = Console.ReadKey(true);
if (pressedKey.KeyChar == '1')
@@ -47,6 +48,10 @@ namespace MQTTnet.TestApp.NetCore
{
Task.Run(ServerAndClientTest.RunAsync);
}
else if (pressedKey.KeyChar == '7')
{
Task.Run(ClientFlowTest.RunAsync);
}

Thread.Sleep(Timeout.Infinite);
}


+ 4
- 0
Tests/MQTTnet.TestApp.UniversalWindows/MQTTnet.TestApp.UniversalWindows.csproj 查看文件

@@ -127,6 +127,10 @@
</Page>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Extensions\MQTTnet.Extensions.ManagedClient\MQTTnet.Extensions.ManagedClient.csproj">
<Project>{C400533A-8EBA-4F0B-BF4D-295C3708604B}</Project>
<Name>MQTTnet.Extensions.ManagedClient</Name>
</ProjectReference>
<ProjectReference Include="..\..\Extensions\MQTTnet.Extensions.Rpc\MQTTnet.Extensions.Rpc.csproj">
<Project>{c444e9c8-95fa-430e-9126-274129de16cd}</Project>
<Name>MQTTnet.Extensions.Rpc</Name>


+ 1
- 2
Tests/MQTTnet.TestApp.UniversalWindows/MainPage.xaml.cs 查看文件

@@ -8,9 +8,9 @@ using Windows.UI.Xaml;
using MQTTnet.Client;
using MQTTnet.Diagnostics;
using MQTTnet.Exceptions;
using MQTTnet.Extensions.ManagedClient;
using MQTTnet.Extensions.Rpc;
using MQTTnet.Implementations;
using MQTTnet.ManagedClient;
using MQTTnet.Protocol;
using MQTTnet.Server;
using MqttClientConnectedEventArgs = MQTTnet.Client.MqttClientConnectedEventArgs;
@@ -613,7 +613,6 @@ namespace MQTTnet.TestApp.UniversalWindows
await mqttClient.SubscribeAsync(new TopicFilterBuilder().WithTopic("my/topic").Build());
await mqttClient.StartAsync(options);
}

}
}
}

正在加载...
取消
保存