public void DirtinessWorksAfterDotNetCollectionConverted() { DotNetHashSet_Lazinator l = new DotNetHashSet_Lazinator(); l.MyHashSetSerialized = new HashSet <ExampleChild>(); l.MyHashSetSerialized.Add(new ExampleChild()); l.SerializeLazinator(); l.IsDirty.Should().BeFalse(); l.DescendantIsDirty.Should().BeFalse(); var firstItem = l.MyHashSetSerialized.First(); l.IsDirty.Should().BeTrue(); // should be true because .Net collection without special _Dirty property has been accessed firstItem.MyLong = 54321; var c = l.CloneLazinatorTyped(); c.MyHashSetSerialized.First().MyLong.Should().Be(54321); }
public void RemoveBufferWorks_DotNetHashSet() { DotNetHashSet_Lazinator lazinator = new DotNetHashSet_Lazinator() { MyHashSetSerialized = new HashSet <ExampleChild>() { GetExampleChild(1), GetExampleChild(2), } }; lazinator.SerializeLazinator(); lazinator.LazinatorMemoryStorage.IsEmpty.Should().BeFalse(); var x = lazinator.MyHashSetSerialized.First().MyExampleGrandchild.MyInt; lazinator.MyHashSetSerialized.First().MyExampleGrandchild.MyInt++; lazinator.MyHashSetSerialized.First().MyExampleGrandchild.LazinatorMemoryStorage.IsEmpty.Should().BeFalse(); lazinator.RemoveBufferInHierarchy(); lazinator.LazinatorMemoryStorage.IsEmpty.Should().BeTrue(); lazinator.MyHashSetSerialized.First().MyExampleGrandchild.LazinatorMemoryStorage.IsEmpty.Should().BeTrue(); lazinator.MyHashSetSerialized.First().MyExampleGrandchild.MyInt.Should().Be(x + 1); lazinator.SerializeLazinator(); lazinator.MyHashSetSerialized.First().MyExampleGrandchild.LazinatorMemoryStorage.IsEmpty.Should().BeFalse(); lazinator.MyHashSetSerialized.First().MyExampleGrandchild.MyInt.Should().Be(x + 1); lazinator.SerializeLazinator(); LazinatorMemory lazinatorMemoryStorage = lazinator.MyHashSetSerialized.First().MyExampleGrandchild.LazinatorMemoryStorage; lazinatorMemoryStorage.Should().NotBeNull(); lazinator.MyHashSetSerialized.First().MyExampleGrandchild.MyInt.Should().Be(x + 1); lazinator.MyHashSetSerialized.First().MyExampleGrandchild.MyInt++; lazinator.SerializeLazinator(); lazinator.MyHashSetSerialized.First().MyExampleGrandchild.LazinatorMemoryStorage.IsEmpty.Should().BeFalse(); (lazinator.MyHashSetSerialized.First().MyExampleGrandchild.LazinatorMemoryStorage == lazinatorMemoryStorage).Should() .BeFalse(); lazinator.MyHashSetSerialized.First().MyExampleGrandchild.MyInt.Should().Be(x + 2); }