﻿using System;
using Xunit;

namespace Carbon.Data.Sequences.Tests
{
    public class UidTests
    {
        [Theory]
        [InlineData(0, 0,                          "0000000000000000000000")]
        [InlineData(1, 1,                          "0000000000100000000001")]
        [InlineData(1, 2,                          "0000000000100000000002")]
        [InlineData(1, 3,                          "0000000000100000000003")]
        [InlineData(long.MaxValue, ulong.MaxValue, "aZl8N0y58M7lYGhA16ahyf")]
        public void A(ulong upper, ulong lower, string hexString)
        {
            var uid = new Uid(upper, lower);

            var a = Uid.Parse(hexString);

            Assert.Equal(upper, a.Upper);
            Assert.Equal(lower, a.Lower);

            Assert.Equal(uid.Serialize(), a.Serialize());
        }

        [Fact]
        public void B()
        {
            for (var i = 0; i < 100_000; i++)
            {
                var guid = Guid.NewGuid();

                Uid id = guid;

                Assert.Equal(id, Uid.Parse(id.ToString()));
                
                Assert.Equal(guid, (Guid)id);
            }
        }

    }
}
