Exemplo n.º 1
0
 public void CompareTo_ByTimestamp_AllDistinctTimestamps()
 {
     foreach (var timestamp1 in TimeGuidBitsLayoutTest.AllDistinctTimestamps(TimeSpan.FromDays(10000)))
     {
         foreach (var timestamp2 in TimeGuidBitsLayoutTest.AllDistinctTimestamps(TimeSpan.FromDays(10)))
         {
             if (timestamp2 == timestamp1)
             {
                 continue;
             }
             var timeGuid1      = TimeGuid.NewGuid(timestamp1);
             var timeGuid2      = TimeGuid.NewGuid(timestamp2);
             var expectedResult = timestamp1.CompareTo(timestamp2);
             Assert.That(timeGuid1.CompareTo(timeGuid2), Is.EqualTo(expectedResult), $"timestamp1 = {timestamp1}, timestamp2 = {timestamp2}");
         }
     }
 }
Exemplo n.º 2
0
        public void CompareTo_ByTimestamp_SequentialTimestamps()
        {
            TimeGuid lastGuid = null;

            foreach (var timestamp in TimeGuidBitsLayoutTest.AllDistinctTimestamps(TimeSpan.FromHours(10)))
            {
                var nextGuid = TimeGuid.NewGuid(timestamp);
                Assert.That(lastGuid < nextGuid);
                Assert.That(nextGuid > lastGuid);
                if (lastGuid != null)
                {
                    Assert.That(nextGuid, Is.GreaterThan(lastGuid));
                    Assert.That(nextGuid.GetTimestamp(), Is.GreaterThan(lastGuid.GetTimestamp()));
                }
                lastGuid = nextGuid;
            }
        }