mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-26 16:24:10 +08:00
fixed clients overlapping from one test to another by:
- adding client and server wrappers to verify the clientid starts with the testname - adding disposable baseclass - clear disconnect handler from client so it does not try to reconnect after it is disposed - moved code from dispose to cleanup in case it is called in a stop method as dispose may only be called once while start / stop may be called multiple times
This commit is contained in:
@@ -18,7 +18,7 @@ namespace MQTTnet.Tests
|
||||
//This test compares
|
||||
//1. correct logID
|
||||
string logId = "logId";
|
||||
bool invalidLogIdOccured = false;
|
||||
string invalidLogId = null;
|
||||
|
||||
//2. if the total log calls are the same for global and local
|
||||
int globalLogCount = 0;
|
||||
@@ -31,7 +31,7 @@ namespace MQTTnet.Tests
|
||||
{
|
||||
if (logId != e.TraceMessage.LogId)
|
||||
{
|
||||
invalidLogIdOccured = true;
|
||||
invalidLogId = e.TraceMessage.LogId;
|
||||
}
|
||||
Interlocked.Increment(ref globalLogCount);
|
||||
});
|
||||
@@ -42,7 +42,7 @@ namespace MQTTnet.Tests
|
||||
{
|
||||
if (logId != e.TraceMessage.LogId)
|
||||
{
|
||||
invalidLogIdOccured = true;
|
||||
invalidLogId = e.TraceMessage.LogId;
|
||||
}
|
||||
Interlocked.Increment(ref localLogCount);
|
||||
};
|
||||
@@ -69,7 +69,7 @@ namespace MQTTnet.Tests
|
||||
MqttNetGlobalLogger.LogMessagePublished -= globalLog;
|
||||
}
|
||||
|
||||
Assert.IsFalse(invalidLogIdOccured);
|
||||
Assert.IsNull(invalidLogId);
|
||||
Assert.AreNotEqual(0, globalLogCount);
|
||||
Assert.AreEqual(globalLogCount, localLogCount);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user