public void Guid_ConvertedTo_Ulid_MaintainsSortOrder() { var smallerGuid = Guid.Parse("01778643-fdff-0006-1c67-0bd309234c7c"); var largerGuid = Guid.Parse("01778643-fe00-0000-2a61-953560310b0f"); Assert.AreEqual(-1, smallerGuid.CompareTo(largerGuid)); var smallerUlid = new Ulid(smallerGuid); var largerUlid = new Ulid(largerGuid); Assert.AreEqual(-1, smallerUlid.CompareTo(largerUlid)); }
public void GuidComparison() { var data_smaller = new byte[] { 0, 255, 255, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; var data_larger = new byte[] { 1, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; var ulid_smaller = new Ulid(data_smaller); var ulid_larger = new Ulid(data_larger); var guid_smaller = ulid_smaller.ToGuid(); var guid_larger = ulid_larger.ToGuid(); ulid_smaller.CompareTo(ulid_larger).Should().BeLessThan(0, "a Ulid comparison should compare byte to byte"); guid_smaller.CompareTo(guid_larger).Should().BeLessThan(0, "a Ulid to Guid cast should preserve order"); }
public int Ulid_() { return(ulid.CompareTo(ulid)); }