public void GetTimestamp() { var timestamp = new Timestamp(tsGenerator.NowTicks()); var timeGuid = TimeGuidBitsLayout.Format(timestamp, RandomClockSequence(), RandomNode()); Assert.That(TimeGuidBitsLayout.GetTimestamp(timeGuid), Is.EqualTo(timestamp)); }
public void MaxGuid() { Assert.That(TimeGuidBitsLayout.MaxTimeGuid, Is.EqualTo(new byte[] { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xbf, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f })); Assert.That(TimeGuidBitsLayout.GetTimestamp(TimeGuidBitsLayout.MaxTimeGuid), Is.EqualTo(new Timestamp(new DateTime(1652084544606846975L, DateTimeKind.Utc).Ticks))); Assert.That(TimeGuidBitsLayout.GetClockSequence(TimeGuidBitsLayout.MaxTimeGuid), Is.EqualTo(16383)); Assert.That(TimeGuidBitsLayout.GetNode(TimeGuidBitsLayout.MaxTimeGuid), Is.EqualTo(new byte[] { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff })); }
public void MinGuid() { Assert.That(TimeGuidBitsLayout.MinTimeGuid, Is.EqualTo(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 })); Assert.That(TimeGuidBitsLayout.GetTimestamp(TimeGuidBitsLayout.MinTimeGuid), Is.EqualTo(new Timestamp(new DateTime(1582, 10, 15, 0, 0, 0, DateTimeKind.Utc).Ticks))); Assert.That(TimeGuidBitsLayout.GetClockSequence(TimeGuidBitsLayout.MinTimeGuid), Is.EqualTo(0)); Assert.That(TimeGuidBitsLayout.GetNode(TimeGuidBitsLayout.MinTimeGuid), Is.EqualTo(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 })); }
public void GetTimestamp_GregorianCalendarEnd() { var timestamp = TimeGuidBitsLayout.GregorianCalendarEnd; var timeGuid = TimeGuidBitsLayout.Format(timestamp, 0, new byte[6]); Assert.That(TimeGuidBitsLayout.GetTimestamp(timeGuid), Is.EqualTo(timestamp)); Assert.That(new Guid(timeGuid), Is.EqualTo(new Guid("ffffffff-ffff-ff1f-8080-808080808080"))); }
public void GenerateByTimestamp() { var guidGen = new TimeGuidGenerator(PreciseTimestampGenerator.Instance); var ts = Timestamp.Now; var guid = guidGen.NewGuid(ts); Assert.That(TimeGuidBitsLayout.GetTimestamp(guid), Is.EqualTo(ts)); }
public void GenerateByTimestampAndClockSequence() { var guidGen = new TimeGuidGenerator(PreciseTimestampGenerator.Instance); var ts = Timestamp.Now; var clockSequence = TimeGuidGenerator.GenerateRandomClockSequence(); var guid = guidGen.NewGuid(ts, clockSequence); Assert.That(TimeGuidBitsLayout.GetTimestamp(guid), Is.EqualTo(ts)); Assert.That(TimeGuidBitsLayout.GetClockSequence(guid), Is.EqualTo(clockSequence)); }
public void GetTimestamp_AllDistinctTimestamps() { var node = RandomNode(); var clockSequence = RandomClockSequence(); foreach (var timestamp in AllDistinctTimestamps(TimeSpan.FromHours(10))) { var timeGuid = TimeGuidBitsLayout.Format(timestamp, clockSequence, node); Assert.That(TimeGuidBitsLayout.GetTimestamp(timeGuid), Is.EqualTo(timestamp)); } }