public void TestDecode_Min32() { var result = Timestamp.Decode(MessagePackSerializer.UnpackMessagePackObject(new byte[] { 0xD6, 0xFF }.Concat(new byte[] { 0, 0, 0, 0 }).ToArray()).AsMessagePackExtendedTypeObject()); Assert.That(result.UnixEpochSecondsPart, Is.EqualTo(0L)); Assert.That(result.NanosecondsPart, Is.EqualTo(0)); Assert.That(result.ToString(), Is.EqualTo("1970-01-01T00:00:00.000000000Z")); }
public void TestDecode_Min64_MinSeconds() { var result = Timestamp.Decode(MessagePackSerializer.UnpackMessagePackObject(new byte[] { 0xD7, 0xFF, 0, 0, 0, 0x1, 0, 0, 0, 0 }).AsMessagePackExtendedTypeObject()); Assert.That(result.UnixEpochSecondsPart, Is.EqualTo(0x100000000L)); Assert.That(result.NanosecondsPart, Is.EqualTo(0)); Assert.That(result.ToString(), Is.EqualTo("2106-02-07T06:28:16.000000000Z")); }
public void TestDecode_Max96() { var result = Timestamp.Decode(MessagePackSerializer.UnpackMessagePackObject(new byte[] { 0xC7, 12, 0xFF }.Concat(new byte[] { 0x3B, 0x9A, 0xC9, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }).ToArray()).AsMessagePackExtendedTypeObject()); Assert.That(result.UnixEpochSecondsPart, Is.EqualTo(9223372036854775807L)); Assert.That(result.NanosecondsPart, Is.EqualTo(999999999)); Assert.That(result.ToString(), Is.EqualTo("292277026596-12-04T15:30:07.999999999Z")); }
public void TestDecode_Min96() { var result = Timestamp.Decode(MessagePackSerializer.UnpackMessagePackObject(new byte[] { 0xC7, 12, 0xFF }.Concat(new byte[] { 0, 0, 0, 0, 0x80, 0, 0, 0, 0, 0, 0, 0 }).ToArray()).AsMessagePackExtendedTypeObject()); Assert.That(result.UnixEpochSecondsPart, Is.EqualTo(-9223372036854775808L)); Assert.That(result.NanosecondsPart, Is.EqualTo(0)); Assert.That(result.ToString(), Is.EqualTo("-292277022657-01-27T08:29:52.000000000Z")); }
public void TestDecode_Max64() { var result = Timestamp.Decode(MessagePackSerializer.UnpackMessagePackObject(new byte[] { 0xD7, 0xFF }.Concat(new byte[] { 0xEE, 0x6B, 0x27, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }).ToArray()).AsMessagePackExtendedTypeObject()); Assert.That(result.UnixEpochSecondsPart, Is.EqualTo(17179869183L)); Assert.That(result.NanosecondsPart, Is.EqualTo(999999999)); Assert.That(result.ToString(), Is.EqualTo("2514-05-30T01:53:03.999999999Z")); }
public void TestDecode_Max32() { var result = Timestamp.Decode(MessagePackSerializer.UnpackMessagePackObject(new byte[] { 0xD6, 0xFF }.Concat(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF }).ToArray()).AsMessagePackExtendedTypeObject()); Assert.That(result.UnixEpochSecondsPart, Is.EqualTo(4294967295L)); Assert.That(result.NanosecondsPart, Is.EqualTo(0)); Assert.That(result.ToString(), Is.EqualTo("2106-02-07T06:28:15.000000000Z")); }
public void TestDecode_InvalidTypeCode() { Assert.Throws <ArgumentException>(() => Timestamp.Decode(default(MessagePackExtendedTypeObject))); }
public void TestDecode_InvalidLength_13() { Assert.Throws <ArgumentException>(() => Timestamp.Decode(MessagePackExtendedTypeObject.Unpack(0xFF, new byte [13]))); }