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)); }
public void CanMigrateStringToEncryptedString() { var parentMapper = new FullNameTypeMapper(); var mapper = new EventStoreTest.OverloadableTypeMapper(typeof(EventWithEncryptedString), parentMapper.ToName(typeof(EventWithString)), parentMapper ); var obj = (EventWithEncryptedString)PassThroughEventStorage(new EventWithString { A = "pass" }, mapper); Assert.Equal("pass", obj.A); var obj2 = (EventWithEncryptedString)PassThroughEventStorage(new EventWithString { A = null }, mapper); Assert.Null(obj2.A.Secret); }
public void CanMigrateStringToVersion() { var parentMapper = new FullNameTypeMapper(); var mapper = new EventStoreTest.OverloadableTypeMapper(typeof(EventWithVersion), parentMapper.ToName(typeof(EventWithString)), parentMapper ); var obj = (EventWithVersion)PassThroughEventStorage(new EventWithString { A = "1.2.3" }, mapper); Assert.Equal(new Version(1, 2, 3), obj.A); var obj2 = (EventWithVersion)PassThroughEventStorage(new EventWithString { A = null }, mapper); Assert.Null(obj2.A); }
public void CanMigrateIntToUlong() { var parentMapper = new FullNameTypeMapper(); var mapper = new EventStoreTest.OverloadableTypeMapper(typeof(EventWithUlong), parentMapper.ToName(typeof(EventWithInt)), parentMapper ); var obj = (EventWithUlong)PassThroughEventStorage(new EventWithInt { A = 42 }, mapper); Assert.Equal(42ul, obj.A); var obj2 = (EventWithUlong)PassThroughEventStorage(new EventWithInt { A = -1 }, mapper); Assert.Equal(0xffffffff, obj2.A); }
public void CanMigrateDictionaryValueOutOfIndirect() { var parentMapper = new FullNameTypeMapper(); var mapper = new EventStoreTest.OverloadableTypeMapper(typeof(EventDictAbstract), parentMapper.ToName(typeof(EventDictIndirectAbstract)), parentMapper ); var obj = PassThroughEventStorage(new EventDictIndirectAbstract { Items = new Dictionary <ulong, IIndirect <ItemBase> > { { 1, new DBIndirect <ItemBase>(new ItemBase1 { A = 1, B = 2 }) } } }, mapper, false); Assert.IsType <EventDictAbstract>(obj); var res = (EventDictAbstract)obj; Assert.Equal(1, res.Items[1].A); Assert.Equal(2, ((ItemBase1)res.Items[1]).B); }
public FullNameTypeMapperTest() { _fullNameTypeMapper = new FullNameTypeMapper(); }