lanlingxian_ziranziyuanhegu.../Infrastructure/Test/TestSnowflake.cs

30 lines
756 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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);
}
}
}