提交 4d508436 编写于 作者: 麦壳饼's avatar 麦壳饼

Add Test for Queue

上级 ea616e57
...@@ -10,7 +10,7 @@ namespace IoTSharp.Test ...@@ -10,7 +10,7 @@ namespace IoTSharp.Test
[TestClass] [TestClass]
public class TestQueue public class TestQueue
{ {
Dictionary<string, object> dic=new Dictionary<string, object> (); Dictionary<string, object> dic = new Dictionary<string, object>();
[TestInitialize] [TestInitialize]
public void InitTest() public void InitTest()
{ {
...@@ -20,7 +20,9 @@ namespace IoTSharp.Test ...@@ -20,7 +20,9 @@ namespace IoTSharp.Test
} }
} }
[TestMethod] [TestMethod]
public void TestSimpleQueue() => TestIMsgQueue<SimpleQueue>(); public void TestSimpleQueue() => TestIMsgQueue<SimpleQueue>();
...@@ -37,17 +39,15 @@ namespace IoTSharp.Test ...@@ -37,17 +39,15 @@ namespace IoTSharp.Test
public void TestIMsgQueue<T>() where T : IMsgQueue, new() public void TestIMsgQueue<T>() where T : IMsgQueue, new()
{ {
List<Task> tasks = new List<Task>();
var t = new T(); var t = new T();
for (int i = 0; i < 10000; i++) 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++) for (int i = 0; i < 10000; i++)
{ {
tasks.Add(Task.Run(() => t.Dequeue())); t.Dequeue();
} }
Task.WaitAll(tasks.ToArray());
} }
private int rep = 0; private int rep = 0;
private string GenerateCheckCodeNum(int codeCount) private string GenerateCheckCodeNum(int codeCount)
......
...@@ -2,14 +2,11 @@ ...@@ -2,14 +2,11 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using MQTTnet; using MQTTnet;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using NodaTime.Extensions;
using Org.BouncyCastle.Asn1.X509.Qualified;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Dic = System.Collections.Generic.Dictionary<string, string>; using Dic = System.Collections.Generic.Dictionary<string, string>;
using DicKV = System.Collections.Generic.KeyValuePair<string, string>;
namespace IoTSharp.Extensions namespace IoTSharp.Extensions
{ {
......
...@@ -56,7 +56,6 @@ ...@@ -56,7 +56,6 @@
<PackageReference Include="MQTTnet" Version="3.0.12-rc1" /> <PackageReference Include="MQTTnet" Version="3.0.12-rc1" />
<PackageReference Include="MQTTnet.AspNetCore" Version="3.0.12-rc1" /> <PackageReference Include="MQTTnet.AspNetCore" Version="3.0.12-rc1" />
<PackageReference Include="MQTTnet.Extensions.Rpc" Version="3.0.12-rc1" /> <PackageReference Include="MQTTnet.Extensions.Rpc" Version="3.0.12-rc1" />
<PackageReference Include="NodaTime" Version="3.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.4" /> <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.4" />
<PackageReference Include="NSwag.AspNetCore" Version="13.6.2" /> <PackageReference Include="NSwag.AspNetCore" Version="13.6.2" />
<PackageReference Include="OptimizedPriorityQueue" Version="4.2.0" /> <PackageReference Include="OptimizedPriorityQueue" Version="4.2.0" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册