OpenAuth.Net/Infrastructure/Test/TestSnowflake.cs

30 lines
756 B
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using NUnit.Framework;
using Yitter.IdGenerator;
namespace Infrastructure.Test
{
class TestSnowflake
{
[Test]
public void Generate()
{
// 全局初始化设置WorkerId默认最大2^16-1。初始化过程全局只需一次且必须最先设置
2021-03-29 23:35:02 +08:00
var options = new IdGeneratorOptions()
{
Method = 1,
WorkerId = 1
};
2021-03-29 23:35:02 +08:00
YitIdHelper.SetIdGenerator(options);
long newId = YitIdHelper.NextId();
Console.WriteLine("=====================================");
Console.WriteLine("生成的 Id" + newId);
}
}
}