From 4d5084367c5140a989935ad095de3672670b069f Mon Sep 17 00:00:00 2001 From: MysticBoy Date: Mon, 3 Aug 2020 16:42:49 +0800 Subject: [PATCH] Add Test for Queue --- IoTSharp.Test/TestQueue.cs | 12 ++++++------ IoTSharp/Extensions/DataExtension.cs | 3 --- IoTSharp/IoTSharp.csproj | 1 - 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/IoTSharp.Test/TestQueue.cs b/IoTSharp.Test/TestQueue.cs index 20b69e14..96a90b02 100644 --- a/IoTSharp.Test/TestQueue.cs +++ b/IoTSharp.Test/TestQueue.cs @@ -10,7 +10,7 @@ namespace IoTSharp.Test [TestClass] public class TestQueue { - Dictionary dic=new Dictionary (); + Dictionary dic = new Dictionary(); [TestInitialize] public void InitTest() { @@ -20,7 +20,9 @@ namespace IoTSharp.Test } } - + + + [TestMethod] public void TestSimpleQueue() => TestIMsgQueue(); @@ -37,17 +39,15 @@ namespace IoTSharp.Test public void TestIMsgQueue() where T : IMsgQueue, new() { - List tasks = new List(); var t = new T(); for (int i = 0; i < 10000; i++) { - tasks.Add( Task.Run(()=> t.Enqueue(new RawMsg() { DataCatalog = Data.DataCatalog.TelemetryData, DataSide = Data.DataSide.AnySide, DeviceId = Guid.NewGuid(), MsgBody = dic, MsgType = MsgType.MQTT }))); + t.Enqueue(new RawMsg() { DataCatalog = Data.DataCatalog.TelemetryData, DataSide = Data.DataSide.AnySide, DeviceId = Guid.NewGuid(), MsgBody = dic, MsgType = MsgType.MQTT }); } for (int i = 0; i < 10000; i++) { - tasks.Add(Task.Run(() => t.Dequeue())); + t.Dequeue(); } - Task.WaitAll(tasks.ToArray()); } private int rep = 0; private string GenerateCheckCodeNum(int codeCount) diff --git a/IoTSharp/Extensions/DataExtension.cs b/IoTSharp/Extensions/DataExtension.cs index 1a05ee5b..6e444edb 100644 --- a/IoTSharp/Extensions/DataExtension.cs +++ b/IoTSharp/Extensions/DataExtension.cs @@ -2,14 +2,11 @@ using Microsoft.EntityFrameworkCore; using MQTTnet; using Newtonsoft.Json.Linq; -using NodaTime.Extensions; -using Org.BouncyCastle.Asn1.X509.Qualified; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Dic = System.Collections.Generic.Dictionary; -using DicKV = System.Collections.Generic.KeyValuePair; namespace IoTSharp.Extensions { diff --git a/IoTSharp/IoTSharp.csproj b/IoTSharp/IoTSharp.csproj index 780e1e7f..719ff5dc 100644 --- a/IoTSharp/IoTSharp.csproj +++ b/IoTSharp/IoTSharp.csproj @@ -56,7 +56,6 @@ - -- GitLab