public void DecrementNode() { Assert.That(TimeGuidBitsLayout.DecrementNode(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }), Is.EqualTo(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 })); Assert.That(TimeGuidBitsLayout.DecrementNode(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0xff }), Is.EqualTo(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe })); Assert.That(TimeGuidBitsLayout.DecrementNode(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 }), Is.EqualTo(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0xff })); Assert.That(TimeGuidBitsLayout.DecrementNode(new byte[] { 0x12, 0x34, 0x56, 0x78, 0xff, 0x00 }), Is.EqualTo(new byte[] { 0x12, 0x34, 0x56, 0x78, 0xfe, 0xff })); Assert.That(TimeGuidBitsLayout.DecrementNode(new byte[] { 0x12, 0x34, 0x56, 0x79, 0x00, 0x00 }), Is.EqualTo(new byte[] { 0x12, 0x34, 0x56, 0x78, 0xff, 0xff })); Assert.That(TimeGuidBitsLayout.DecrementNode(new byte[] { 0x12, 0xff, 0x00, 0x00, 0x00, 0x00 }), Is.EqualTo(new byte[] { 0x12, 0xfe, 0xff, 0xff, 0xff, 0xff })); Assert.That(TimeGuidBitsLayout.DecrementNode(new byte[] { 0x13, 0x00, 0x00, 0x00, 0x00, 0x00 }), Is.EqualTo(new byte[] { 0x12, 0xff, 0xff, 0xff, 0xff, 0xff })); Assert.That(TimeGuidBitsLayout.DecrementNode(new byte[] { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 }), Is.EqualTo(new byte[] { 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff })); Assert.That(TimeGuidBitsLayout.DecrementNode(new byte[] { 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }), Is.EqualTo(new byte[] { 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff })); Assert.That(TimeGuidBitsLayout.DecrementNode(new byte[] { 0xff, 0xff, 0xff, 0xff, 0xff, 0x00 }), Is.EqualTo(new byte[] { 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff })); Assert.That(TimeGuidBitsLayout.DecrementNode(new byte[] { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }), Is.EqualTo(new byte[] { 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe })); Assert.Throws <InvalidOperationException>(() => TimeGuidBitsLayout.DecrementNode(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 })); }
public void Before() { var timestamp = Timestamp.Now; Assert.That(TimeGuid.MaxForTimestamp(timestamp).Before(), Is.LessThan(TimeGuid.MaxForTimestamp(timestamp))); Assert.That(TimeGuid.MinForTimestamp(timestamp).Before(), Is.EqualTo(TimeGuid.MaxForTimestamp(timestamp - TimeSpan.FromTicks(1)))); Assert.That(new TimeGuid(timestamp, 1, TimeGuidBitsLayout.MinNode).Before(), Is.EqualTo(new TimeGuid(timestamp, 0, TimeGuidBitsLayout.MaxNode))); Assert.That(new TimeGuid(timestamp, 1, TimeGuidBitsLayout.MaxNode).Before(), Is.EqualTo(new TimeGuid(timestamp, 1, TimeGuidBitsLayout.DecrementNode(TimeGuidBitsLayout.MaxNode)))); Assert.Throws <InvalidOperationException>(() => TimeGuid.MinForTimestamp(new Timestamp(DateTime.MinValue))); }