提交 5066a060 编写于 作者: 麦壳饼's avatar 麦壳饼

remove queue

上级 11cf8b47
using IoTSharp.Queue;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace IoTSharp.Test
{
[TestClass]
public class TestQueue
{
Dictionary<string, object> dic = new Dictionary<string, object>();
[TestInitialize]
public void InitTest()
{
for (int ix = 0; ix < 10; ix++)
{
dic.Add($"key_{ix}", GenerateCheckCodeNum(1000));
}
}
[TestMethod]
public void TestSimpleQueue() => TestIMsgQueue<SimpleQueue>();
[TestMethod]
public void TestFastQueue() => TestIMsgQueue<FastQueue>();
[TestMethod]
public void TestDiskQueue() => TestIMsgQueue<LiteDBQueue>();
[TestMethod]
public void TestMemoryQueue() => TestIMsgQueue<MemoryQueue>();
public void TestIMsgQueue<T>() where T : IMsgQueue, new()
{
var t = new T();
for (int i = 0; i < 10000; i++)
{
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++)
{
t.Dequeue();
}
}
private int rep = 0;
private string GenerateCheckCodeNum(int codeCount)
{
string str = string.Empty;
long num2 = DateTime.Now.Ticks + this.rep;
this.rep++;
Random random = new Random(((int)(((ulong)num2) & 0xffffffffL)) | ((int)(num2 >> this.rep)));
for (int i = 0; i < codeCount; i++)
{
int num = random.Next();
str = str + ((char)(0x30 + ((ushort)(num % 10)))).ToString();
}
return str;
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册