예제 #1
0
        public void Test_VersionStamp_To_Uuid96()
        {
            // To
            Assert.That(VersionStamp.Incomplete(0xFFFF).ToUuid96(), Is.EqualTo(Uuid96.MaxValue));
            Assert.That(VersionStamp.Incomplete(0x1234).ToUuid96(), Is.EqualTo(new Uuid96(0xFFFFFFFF, 0xFFFFFFFFFFFF1234UL)));
            Assert.That(VersionStamp.Complete(0x0123456789ABCDEF, 0x55AA, 0x33CC).ToUuid96(), Is.EqualTo(new Uuid96(0x01234567U, 0x89ABCDEF55AA33CCUL)));

            // From
            Assert.That(VersionStamp.FromUuid96(Uuid96.MaxValue), Is.EqualTo(VersionStamp.Incomplete(0xFFFF)));
            Assert.That(VersionStamp.FromUuid96(new Uuid96(0xFFFFFFFF, 0xFFFFFFFFFFFF1234UL)), Is.EqualTo(VersionStamp.Incomplete(0x1234)));
            Assert.That(VersionStamp.FromUuid96(new Uuid96(0x01234567U, 0x89ABCDEF55AA33CCUL)), Is.EqualTo(VersionStamp.Complete(0x0123456789ABCDEF, 0x55AA, 0x33CC)));

            // cast
            Assert.That((Uuid96)VersionStamp.Incomplete(0xFFFF), Is.EqualTo(Uuid96.MaxValue));
            Assert.That((Uuid96)VersionStamp.Incomplete(0x1234), Is.EqualTo(new Uuid96(0xFFFFFFFF, 0xFFFFFFFFFFFF1234UL)));
            Assert.That((Uuid96)VersionStamp.Complete(0x0123456789ABCDEF, 0x55AA, 0x33CC), Is.EqualTo(new Uuid96(0x01234567U, 0x89ABCDEF55AA33CCUL)));
            Assert.That((VersionStamp)Uuid96.MaxValue, Is.EqualTo(VersionStamp.Incomplete(0xFFFF)));
            Assert.That((VersionStamp) new Uuid96(0xFFFFFFFF, 0xFFFFFFFFFFFF1234UL), Is.EqualTo(VersionStamp.Incomplete(0x1234)));
            Assert.That((VersionStamp) new Uuid96(0x01234567U, 0x89ABCDEF55AA33CCUL), Is.EqualTo(VersionStamp.Complete(0x0123456789ABCDEF, 0x55AA, 0x33CC)));

            // should fail if size does not match
            Assert.That(() => VersionStamp.Incomplete().ToUuid96(), Throws.Exception);
            Assert.That(() => VersionStamp.Complete(0x0123456789ABCDEF, 0x55AA).ToUuid96(), Throws.Exception);
        }