示例#1
0
        public void ReadAll()
        {
            var idLarge = LargeBlobId();
            var id11    = RegularBlobId();
            var id12    = RegularBlobId();
            var shift   = Timestamp.Now.AddDays(1);
            var id21    = RegularBlobId(TimeGuid.NewGuid(shift));
            var id22    = RegularBlobId(TimeGuid.NewGuid(shift));

            WriteByte(idLarge, 255);
            WriteByte(id11, 11);
            WriteByte(id12, 12);
            WriteByte(id21, 21);
            WriteByte(id22, 22);

            timeBasedBlobStorage.ReadAll(1)
            .Select(x => Tuple.Create(x.Item1, x.Item2.Single()))
            .Should()
            .BeEquivalentTo(new[]
            {
                new Tuple <BlobId, byte>(idLarge, 255),
                new Tuple <BlobId, byte>(id11, 11),
                new Tuple <BlobId, byte>(id12, 12),
                new Tuple <BlobId, byte>(id21, 21),
                new Tuple <BlobId, byte>(id22, 22),
            });
        }
        public void SetUp()
        {
            var now = Timestamp.Now;

            g1          = TimeGuid.NewGuid(now);
            g2          = TimeGuid.NewGuid(now);
            g11         = new TimeGuid(g1.ToByteArray());
            g1PlusDelta = TimeGuid.NewGuid(now + TimeSpan.FromSeconds(1));
        }
 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}");
         }
     }
 }
        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;
            }
        }
示例#5
0
        public void Read_MultipleKeys_DifferentRows()
        {
            var id1     = RegularBlobId(TimeGuid.NewGuid(Timestamp.Now.Add(TimeSpan.FromDays(1))));
            var id2     = RegularBlobId(TimeGuid.NewGuid(Timestamp.Now.Add(TimeSpan.FromDays(-1))));
            var id3     = LargeBlobId();
            var id4     = LargeBlobId();
            var allKeys = new[] { id1, id2, id3, id4 };

            WriteByte(id1, 1);
            WriteByte(id2, 2);
            WriteByte(id3, 3);
            WriteByte(id4, 4);
            var result = timeBasedBlobStorage.Read(allKeys);

            Assert.That(result.Count, Is.EqualTo(4));
            Assert.That(result[id1].Single(), Is.EqualTo(1));
            Assert.That(result[id2].Single(), Is.EqualTo(2));
            Assert.That(result[id3].Single(), Is.EqualTo(3));
            Assert.That(result[id4].Single(), Is.EqualTo(4));
        }
        public void GetClockSequence()
        {
            var clockSequence = TimeGuidGenerator.GenerateRandomClockSequence();

            Assert.That(TimeGuid.NewGuid(Timestamp.Now, clockSequence).GetClockSequence(), Is.EqualTo(clockSequence));
        }
        public void GetTimestamp()
        {
            var ts = Timestamp.Now;

            Assert.That(TimeGuid.NewGuid(ts).GetTimestamp(), Is.EqualTo(ts));
        }
 private static TimeGuid NewExceptionInfoId(ushort c)
 {
     return(TimeGuid.NewGuid(Timestamp.Now, c));
 }