public void MapWithExistingReferencedValueDetectsChangesInValue() { var mps = new MapAndSerializers(SerializerFactories.Default); var peter = new Person() { Name = "Peter" }; ISerializerFactory serializerFactory = new PersistableSerializer2(); var peterSerializer = serializerFactory.CreateSerializer(peter); mps.Add(0, peterSerializer, new Map2(mps)); var ole = new Person { Name = "Ole" }; var existingValues = new[] { SerializerOrValue.CreateSerializer("Person", peterSerializer, 0) }; var map = new Map2(mps, existingValues); map.PullChangedEntries().ShouldBeEmpty(); map["Person"] = peter; map.PullChangedEntries().ShouldBeEmpty(); map["Person"] = ole; var changes = map.PullChangedEntries().ToArray(); changes.Length.ShouldBe(1); changes[0].Key.ShouldBe("Person"); changes[0].HoldsSerializer.ShouldBeTrue(); changes[0].SerializerAndObjectId.ObjectId.ShouldBe(1); changes[0].SerializerAndObjectId.Serializer.Instance.ShouldBe(ole); }
public void MapWithExistingSimpleValueDetectsChangesInValue() { var mps = new MapAndSerializers(SerializerFactories.Default); var existingValues = new[] { SerializerOrValue.CreateValue("Name", "Peter") }; var map = new Map2(mps, existingValues); map.PullChangedEntries().ShouldBeEmpty(); map["Name"] = "Peter"; map.PullChangedEntries().ShouldBeEmpty(); map["Name"] = "Ole"; var changes = map.PullChangedEntries().ToArray(); changes.Length.ShouldBe(1); changes[0].Key.ShouldBe("Name"); changes[0].HoldsSerializer.ShouldBeFalse(); changes[0].Value.ShouldBe("Ole"); }