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:
JanEggers
2019-12-20 15:37:23 +01:00
parent 624fafc662
commit 14419e4d63
22 changed files with 486 additions and 170 deletions
@@ -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);
}