OpenAuth.Net/Infrastructure/Test/TestSnowflake.cs
2021-03-29 23:35:02 +08:00

30 lines
756 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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。初始化过程全局只需一次且必须最先设置
var options = new IdGeneratorOptions()
{
Method = 1,
WorkerId = 1
};
YitIdHelper.SetIdGenerator(options);
long newId = YitIdHelper.NextId();
Console.WriteLine("=====================================");
Console.WriteLine("生成的 Id" + newId);
}
}
}