public void DeserializeSimpleClass() { var serializer = new EventSerializer(); bool hasMetadata; var obj = new User { Name = "Boris", Age = 40 }; var meta = serializer.Serialize(out hasMetadata, obj).ToAsyncSafe(); serializer.ProcessMetadataLog(meta); var data = serializer.Serialize(out hasMetadata, obj); var deserializer = new EventDeserializer(); object obj2; Assert.False(deserializer.Deserialize(out obj2, data)); deserializer.ProcessMetadataLog(meta); Assert.True(deserializer.Deserialize(out obj2, data)); Assert.Equal(obj, obj2); }
public void CanMigrateListInDict() { var obj = PassThroughEventStorage(new EventDictListRoot { Items = new Dictionary<ulong, IList<Item>> { { 1, new List<Item> { new Item { Field = "A" } } } } }, new FullNameTypeMapper()); var serializer = new EventSerializer(); bool hasMetadata; var meta = serializer.Serialize(out hasMetadata, obj).ToAsyncSafe(); serializer.ProcessMetadataLog(meta); var data = serializer.Serialize(out hasMetadata, obj); var deserializer = new EventDeserializer(); object obj2; Assert.False(deserializer.Deserialize(out obj2, data)); deserializer.ProcessMetadataLog(meta); Assert.True(deserializer.Deserialize(out obj2, data)); }
public void CanMigrateListWithNewFields() { var parentMapper = new FullNameTypeMapper(); var mapper = new EventStoreTest.OverloadableTypeMapper(typeof(Item2), parentMapper.ToName(typeof(Item)), new EventStoreTest.OverloadableTypeMapper(typeof(EventRoot2), parentMapper.ToName(typeof(EventRoot)), parentMapper )); var obj = PassThroughEventStorage(new EventRoot { Items = new List<Item> { new Item { Field = "A" } } }, mapper); var serializer = new EventSerializer(mapper); bool hasMetadata; var meta = serializer.Serialize(out hasMetadata, obj).ToAsyncSafe(); serializer.ProcessMetadataLog(meta); var data = serializer.Serialize(out hasMetadata, obj); var deserializer = new EventDeserializer(mapper); object obj2; Assert.False(deserializer.Deserialize(out obj2, data)); deserializer.ProcessMetadataLog(meta); Assert.True(deserializer.Deserialize(out obj2, data)); }