Skip to content

Commit 8d5092d

Browse files
author
Anton Smolkov
committed
Add more tests for session injection
1 parent 57f245c commit 8d5092d

File tree

4 files changed

+420
-48
lines changed

4 files changed

+420
-48
lines changed

Source/MQTTnet.Server/Options/MqttServerOptionsBuilder.cs

+6
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ public MqttServerOptionsBuilder WithMaxPendingMessagesPerClient(int value)
115115
return this;
116116
}
117117

118+
public MqttServerOptionsBuilder WithPendingMessagesOverflowStrategy(MqttPendingMessagesOverflowStrategy value)
119+
{
120+
_options.PendingMessagesOverflowStrategy = value;
121+
return this;
122+
}
123+
118124
public MqttServerOptionsBuilder WithoutDefaultEndpoint()
119125
{
120126
_options.DefaultEndpointOptions.IsEnabled = false;

Source/MQTTnet.Tests/BaseTestClass.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ namespace MQTTnet.Tests
1313
public abstract class BaseTestClass
1414
{
1515
public TestContext TestContext { get; set; }
16-
17-
protected TestEnvironment CreateTestEnvironment(MqttProtocolVersion protocolVersion = MqttProtocolVersion.V311)
16+
17+
protected TestEnvironment CreateTestEnvironment(
18+
MqttProtocolVersion protocolVersion = MqttProtocolVersion.V311, bool trackUnobservedTaskException = true)
1819
{
19-
return new TestEnvironment(TestContext, protocolVersion);
20+
return new TestEnvironment(TestContext, protocolVersion, trackUnobservedTaskException);
2021
}
2122

2223
protected Task LongTestDelay()

Source/MQTTnet.Tests/Mockups/TestEnvironment.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@ public TestEnvironment() : this(null)
3232
{
3333
}
3434

35-
public TestEnvironment(TestContext testContext, MqttProtocolVersion protocolVersion = MqttProtocolVersion.V311)
35+
public TestEnvironment(
36+
TestContext testContext, MqttProtocolVersion protocolVersion = MqttProtocolVersion.V311, bool trackUnobservedTaskException = true)
3637
{
3738
_protocolVersion = protocolVersion;
3839
TestContext = testContext;
3940

40-
TaskScheduler.UnobservedTaskException += TrackUnobservedTaskException;
41+
if (trackUnobservedTaskException)
42+
{
43+
TaskScheduler.UnobservedTaskException += TrackUnobservedTaskException;
44+
}
4145

4246
ServerLogger.LogMessagePublished += (s, e) =>
4347
{

0 commit comments

Comments
 (0)