private void Check(HazMaps obj) { /* * { * DateTimeMapMarkedPropertyLevel = { { 1, date } }, * DateTimeMapMarkedViaMap = { { 2, date } }, * DateTimeNotValidMapButMarked = { { date, date } }, * TimeSpanMapMarkedPropertyLevel = { { "a", time } }, * TimeSpanMapMarkedViaMap = { { "b", time } }, * TimeSpanNotValidMapButMarked = { { time, time } }, * }; */ var date = new DateTime(2020, 05, 31, 0, 0, 0, DateTimeKind.Utc); var time = TimeSpan.FromMinutes(60); var a = Assert.Single(obj.DateTimeMapMarkedPropertyLevel); Assert.Equal(1, a.Key); Assert.Equal(date, a.Value); var b = Assert.Single(obj.DateTimeMapMarkedViaMap); Assert.Equal(2, b.Key); Assert.Equal(date, b.Value); var c = Assert.Single(obj.DateTimeNotValidMapButMarked); Assert.Equal(date, c.Key); Assert.Equal(date, c.Value); var d = Assert.Single(obj.TimeSpanMapMarkedPropertyLevel); Assert.Equal("a", d.Key); Assert.Equal(time, d.Value); var e = Assert.Single(obj.TimeSpanMapMarkedViaMap); Assert.Equal("b", e.Key); Assert.Equal(time, e.Value); var f = Assert.Single(obj.TimeSpanNotValidMapButMarked); Assert.Equal(time, f.Key); Assert.Equal(time, f.Value); }
public void AssertVanillaMapsPayload() // from 2.4 binary { var date = new DateTime(2020, 05, 31, 0, 0, 0, DateTimeKind.Utc); var time = TimeSpan.FromMinutes(60); var obj = new HazMaps { DateTimeMapMarkedPropertyLevel = { { 1, date } }, DateTimeMapMarkedViaMap = { { 2, date } }, DateTimeNotValidMapButMarked = { { date, date } }, TimeSpanMapMarkedPropertyLevel = { { "a", time } }, TimeSpanMapMarkedViaMap = { { "b", time } }, TimeSpanNotValidMapButMarked = { { time, time } }, }; using var ms = new MemoryStream(); Serializer.Serialize(ms, obj); var hex = BitConverter.ToString(ms.GetBuffer(), 0, (int)ms.Length); Assert.Equal("0A-08-08-01-12-04-08-DA-9F-02-12-0A-08-02-12-06-08-80-E7-CB-F6-05-1A-0C-0A-04-08-DA-9F-02-12-04-08-DA-9F-02-22-09-0A-01-61-12-04-08-02-10-01-2A-08-0A-01-62-12-03-08-90-1C-32-0C-0A-04-08-02-10-01-12-04-08-02-10-01", hex, ignoreCase: true); /* * notes: * .bcl.DateTime is days by default, so: 18413 * .google.protobuf.Timestamp is seconds, so: 1590883200 * .bcl.TimeSpan allows hours, so: 1 * .google.protobuf.Duration is seconds, so: 3600 * * // DateTimeMapMarkedPropertyLevel: map<int, .bcl.DateTime> * 0A = field 1, type String * 08 = length 8 * payload = 08-01-12-04-08-DA-9F-02 * 08 = field 1, type Variant * 01 = 1 (raw) or -1 (zigzag) * 12 = field 2, type String * 04 = length 4 * payload = 08-DA-9F-02 * 08 = field 1, type Variant * DA-9F-02 = 36826 (raw) or 18413 (zigzag) * * // DateTimeMapMarkedViaMap: map<int, .google.protobuf.Timestamp> * 12 = field 2, type String * 0A = length 10 * payload = 08-02-12-06-08-80-E7-CB-F6-05 * 08 = field 1, type Variant * 02 = 2 (raw) or 1 (zigzag) * 12 = field 2, type String * 06 = length 6 * payload = 08-80-E7-CB-F6-05 * 08 = field 1, type Variant * 80-E7-CB-F6-05 = 1590883200 (raw) or 795441600 (zigzag) * * // DateTimeNotValidMapButMarked: map<.bcl.DateTime, .bcl.DateTime> * 1A = field 3, type String * 0C = length 12 * payload = 0A-04-08-DA-9F-02-12-04-08-DA-9F-02 * 0A = field 1, type String * 04 = length 4 * payload = 08-DA-9F-02 * 08 = field 1, type Variant * DA-9F-02 = 36826 (raw) or 18413 (zigzag) * 12 = field 2, type String * 04 = length 4 * payload = 08-DA-9F-02 * 08 = field 1, type Variant * DA-9F-02 = 36826 (raw) or 18413 (zigzag) * * // TimeSpanMapMarkedPropertyLevel: map<string, .bcl.TimeSpan> * 22 = field 4, type String * 09 = length 9 * payload = 0A-01-61-12-04-08-02-10-01 * 0A = field 1, type String * 01 = length 1 * payload = 61 * UTF8: a * 12 = field 2, type String * 04 = length 4 * payload = 08-02-10-01 * 08 = field 1, type Variant * 02 = 2 (raw) or 1 (zigzag) * 10 = field 2, type Variant * 01 = 1 (raw) or -1 (zigzag) * * // TimeSpanMapMarkedViaMap: map<string, .google.protobuf.Duration> * 2A = field 5, type String * 08 = length 8 * payload = 0A-01-62-12-03-08-90-1C * 0A = field 1, type String * 01 = length 1 * payload = 62 * UTF8: b * 12 = field 2, type String * 03 = length 3 * payload = 08-90-1C * 08 = field 1, type Variant * 90-1C = 3600 (raw) or 1800 (zigzag) * * // TimeSpanNotValidMapButMarked: map<.bcl.TimeSpan, .bcl.TimeSpan> * 32 = field 6, type String * 0C = length 12 * payload = 0A-04-08-02-10-01-12-04-08-02-10-01 * 0A = field 1, type String * 04 = length 4 * payload = 08-02-10-01 * 08 = field 1, type Variant * 02 = 2 (raw) or 1 (zigzag) * 10 = field 2, type Variant * 01 = 1 (raw) or -1 (zigzag) * 12 = field 2, type String * 04 = length 4 * payload = 08-02-10-01 * 08 = field 1, type Variant * 02 = 2 (raw) or 1 (zigzag) * 10 = field 2, type Variant * 01 = 1 (raw) or -1 (zigzag) */ }