소스 검색

Add UnitTests.

release/3.x.x
Christian Kratky 5 년 전
부모
커밋
0257e31910
1개의 변경된 파일34개의 추가작업 그리고 0개의 파일을 삭제
  1. +34
    -0
      Tests/MQTTnet.Core.Tests/Server_Tests.cs

+ 34
- 0
Tests/MQTTnet.Core.Tests/Server_Tests.cs 파일 보기

@@ -12,6 +12,7 @@ using MQTTnet.Client.Connecting;
using MQTTnet.Client.Disconnecting;
using MQTTnet.Client.Options;
using MQTTnet.Client.Receiving;
using MQTTnet.Client.Subscribing;
using MQTTnet.Protocol;
using MQTTnet.Server;
using MQTTnet.Tests.Mockups;
@@ -174,6 +175,39 @@ namespace MQTTnet.Tests
}
}

[TestMethod]
public async Task Subscribe_Multiple_In_Single_Request()
{
using (var testEnvironment = new TestEnvironment())
{
var receivedMessagesCount = 0;

await testEnvironment.StartServerAsync();

var c1 = await testEnvironment.ConnectClientAsync();
c1.UseApplicationMessageReceivedHandler(c => Interlocked.Increment(ref receivedMessagesCount));
await c1.SubscribeAsync(new MqttClientSubscribeOptionsBuilder()
.WithTopicFilter("a")
.WithTopicFilter("b")
.WithTopicFilter("c")
.Build());

var c2 = await testEnvironment.ConnectClientAsync();

await c2.PublishAsync("a");
await Task.Delay(100);
Assert.AreEqual(receivedMessagesCount, 1);

await c2.PublishAsync("b");
await Task.Delay(100);
Assert.AreEqual(receivedMessagesCount, 2);

await c2.PublishAsync("c");
await Task.Delay(100);
Assert.AreEqual(receivedMessagesCount, 3);
}
}

[TestMethod]
public async Task Publish_From_Server()
{


불러오는 중...
취소
저장