public void Deserialize_VerifyEquivalent() { var se = new SampleEvent { Timestamp = DateTime.Parse("2014-01-20 8:00am"), UnitId = 6 }; var serializer = new DatasourceRecordSerializer(); var ms = new MemoryStream(); serializer.Serialize(ms, new List <DatasourceRecord> { se }); var records = serializer.Deserialize(ms); var deserialized = records[0] as SampleEvent; se.Equivalent(deserialized); }
public void Deserialize_VerifyEquivalent() { var dr = new EventRecord { Timestamp = DateTime.Parse("2014-01-20 8:00am"), MetaData = new Dictionary <int, byte[]> { { 1, new byte[] { 1, 2, 3 } } } }; var serializer = new DatasourceRecordSerializer(); var ms = new MemoryStream(); serializer.Serialize(ms, new List <DatasourceRecord> { dr }); ms.Position = 0; var records = serializer.Deserialize(ms); var deserialized = records[0] as EventRecord; dr.Equivalent(deserialized); }
public void Serialize_Deserialize_NoDataLoss_DoubleValue() { var s = new DatasourceRecordSerializer(); var ms = new MemoryStream(); var recs = new List <DatasourceRecord> { new DatasourceRecord { DatasourceId = 1, IntervalSeconds = 1, Timestamp = DateTime.Parse("2013-11-11") }, new DatasourceRecord { DatasourceId = 2, IntervalSeconds = 2, Timestamp = DateTime.Parse("2013-11-12") } }; recs[0].SetDoubleValue(1.05D); recs[1].SetDoubleValue(2.05D); s.Serialize(ms, recs); ms.Position = 0; var outRecs = s.Deserialize(ms); Assert.AreNotEqual(recs, outRecs); Assert.AreEqual(2, outRecs.Count); Assert.AreEqual(2, outRecs[1].DatasourceId); Assert.AreEqual(2, outRecs[1].IntervalSeconds); Assert.AreEqual(DatasourceRecord.DataTypeEnum.Double, outRecs[1].DataType); Assert.AreEqual(DateTime.Parse("2013-11-12"), outRecs[1].Timestamp); Assert.AreEqual(2.05D, outRecs[1].GetDoubleValue()); }