public void MaxForTimestamp()
        {
            var timestamp           = Timestamp.Now;
            var maxGuidForTimestamp = TimeGuid.MaxForTimestamp(timestamp);

            Assert.That(maxGuidForTimestamp.GetTimestamp(), Is.EqualTo(timestamp));
            Assert.That(maxGuidForTimestamp.GetClockSequence(), Is.EqualTo(TimeGuidBitsLayout.MaxClockSequence));
            Assert.That(maxGuidForTimestamp.GetNode(), Is.EqualTo(TimeGuidBitsLayout.MaxNode));
        }
        public void Before()
        {
            var timestamp = Timestamp.Now;

            Assert.That(TimeGuid.MaxForTimestamp(timestamp).Before(), Is.LessThan(TimeGuid.MaxForTimestamp(timestamp)));
            Assert.That(TimeGuid.MinForTimestamp(timestamp).Before(), Is.EqualTo(TimeGuid.MaxForTimestamp(timestamp - TimeSpan.FromTicks(1))));
            Assert.That(new TimeGuid(timestamp, 1, TimeGuidBitsLayout.MinNode).Before(), Is.EqualTo(new TimeGuid(timestamp, 0, TimeGuidBitsLayout.MaxNode)));
            Assert.That(new TimeGuid(timestamp, 1, TimeGuidBitsLayout.MaxNode).Before(), Is.EqualTo(new TimeGuid(timestamp, 1, TimeGuidBitsLayout.DecrementNode(TimeGuidBitsLayout.MaxNode))));
            Assert.Throws <InvalidOperationException>(() => TimeGuid.MinForTimestamp(new Timestamp(DateTime.MinValue)));
        }
        public void IsTimeGuid()
        {
            Assert.That(TimeGuid.IsTimeGuid(Guid.NewGuid()), Is.False);
            Assert.That(TimeGuid.IsTimeGuid(minGuid), Is.False);
            Assert.That(TimeGuid.IsTimeGuid(maxGuid), Is.False);

            Assert.That(TimeGuid.IsTimeGuid(TimeGuid.NowGuid().ToGuid()), Is.True);
            Assert.That(TimeGuid.IsTimeGuid(TimeGuid.MinValue.ToGuid()), Is.True);
            Assert.That(TimeGuid.IsTimeGuid(TimeGuid.MaxValue.ToGuid()), Is.True);
            Assert.That(TimeGuid.IsTimeGuid(TimeGuid.MinForTimestamp(TimeGuidBitsLayout.GregorianCalendarStart).ToGuid()), Is.True);
            Assert.That(TimeGuid.IsTimeGuid(TimeGuid.MaxForTimestamp(TimeGuidBitsLayout.GregorianCalendarEnd).ToGuid()), Is.True);
        }
 public void MaxForTimestamp_ForGregorianCalendarEnd()
 {
     Assert.That(TimeGuid.MaxForTimestamp(TimeGuidBitsLayout.GregorianCalendarEnd), Is.EqualTo(TimeGuid.MaxValue));
 }