public void EncodeDecodeWithGuidTest(int c) { var gen = new UlidGen(); for (var i = 0; i < c; i++) { var id = gen.Generate(); Ulid .Decode(id.Encode()) .ToGuid() .ShouldBe(id.ToGuid()); } }
public void DistinctUniqueTest(int c) { var gen = new UlidGen(); var l = new List <Ulid>(); for (var i = 0; i < c; i++) { l.Add(gen.Generate()); } l.Distinct() .Count() .ShouldBe(l.Count); }
public void GuidTest(int c) { var gen = new UlidGen(); var l = new List <Ulid>(); var ls = new List <Guid>(); for (var i = 0; i < c; i++) { l.Add(gen.Generate()); ls.Add(l[i].ToGuid()); } for (var i = 0; i < l.Count; i++) { var ulid = Ulid.FromGuid(ls[i]); ulid.ShouldBe(l[i], $"{ulid} != {l[i]} at {i} element!"); } }
public void SortEncodedTest(int c) { var gen = new UlidGen(); var l = new List <Ulid>(); var ls = new List <string>(); for (var i = 0; i < c; i++) { l.Add(gen.Generate()); ls.Add(l[i].Encode()); } ls.Sort(); for (var i = 0; i < l.Count; i++) { ls[i].ShouldBe(l[i].Encode(), $"{ls[i]} != {l[i]} at {i} element!"); } }
public Guid FastUlidV() => _myUlidGen.Generate().ToGuid();