public void BuffersUpdateInTandem_RecordLikeContainer() { RecordLikeContainer e = new RecordLikeContainer { MyRecordLikeTypeWithLazinator = new RecordLikeTypeWithLazinator(5, "May", GetTypicalExample(), new ExampleStructWithoutClass() { MyInt = 17 }), }; e = e.CloneLazinatorTyped(); ConfirmBuffersUpdateInTandem(e); e = e.CloneLazinatorTyped(); e.MyInt = 25; // make container dirty ConfirmBuffersUpdateInTandem(e); }
public void RemoveBufferWorks_RecordLikeContainer() { RecordLikeContainer recordLikeContainer = new RecordLikeContainer { MyRecordLikeTypeWithLazinator = new RecordLikeTypeWithLazinator(5, "May", GetTypicalExample(), new ExampleStructWithoutClass() { MyInt = 17 }) }; recordLikeContainer = recordLikeContainer.CloneLazinatorTyped(); recordLikeContainer.MyRecordLikeClass = new RecordLikeClass(3, GetTypicalExample()); // make outer class dirty recordLikeContainer.RemoveBufferInHierarchy(); recordLikeContainer.MyRecordLikeTypeWithLazinator.Example.MyDateTime.Should().Be(new DateTime(1972, 10, 22, 17, 36, 0)); recordLikeContainer.MyRecordLikeTypeWithLazinator.ExampleStruct.MyInt.Should().Be(17); recordLikeContainer.MyRecordLikeTypeWithLazinator.Example.LazinatorMemoryStorage.IsEmpty.Should().BeTrue(); recordLikeContainer.MyRecordLikeTypeWithLazinator.ExampleStruct.LazinatorMemoryStorage.IsEmpty.Should().BeTrue(); var x = recordLikeContainer.MyRecordLikeTypeWithLazinator.Example.MyChar; recordLikeContainer.SerializeLazinator(); // should remove the buffer within the struct recordLikeContainer.MyRecordLikeTypeWithLazinator.Example.MyDateTime.Should().Be(new DateTime(1972, 10, 22, 17, 36, 0)); recordLikeContainer.MyRecordLikeTypeWithLazinator.ExampleStruct.MyInt.Should().Be(17); recordLikeContainer.LazinatorMemoryStorage.IsEmpty.Should().BeFalse(); recordLikeContainer.MyRecordLikeTypeWithLazinator.Example.LazinatorMemoryStorage.IsEmpty.Should().BeTrue(); recordLikeContainer.MyRecordLikeTypeWithLazinator.ExampleStruct.LazinatorMemoryStorage.IsEmpty.Should().BeTrue(); recordLikeContainer = recordLikeContainer.CloneLazinatorTyped(); recordLikeContainer.MyRecordLikeClass = new RecordLikeClass(3, GetTypicalExample()); // make outer class dirty recordLikeContainer.SerializeLazinator(); recordLikeContainer.MyRecordLikeTypeWithLazinator.Example.MyDateTime.Should().Be(new DateTime(1972, 10, 22, 17, 36, 0)); recordLikeContainer.MyRecordLikeTypeWithLazinator.ExampleStruct.MyInt.Should().Be(17); recordLikeContainer.LazinatorMemoryStorage.IsEmpty.Should().BeFalse(); recordLikeContainer.MyRecordLikeTypeWithLazinator.Example.LazinatorMemoryStorage.IsEmpty.Should().BeFalse(); // this will be first access to MyRecordLikeTypeWithLazinator.Example, so that will lead to the memory allocation recordLikeContainer.MyRecordLikeTypeWithLazinator.ExampleStruct.LazinatorMemoryStorage.IsEmpty.Should().BeFalse(); recordLikeContainer.MyRecordLikeTypeWithLazinator.Example.LazinatorMemoryStorage.AllocationID.Should().Be( recordLikeContainer.LazinatorMemoryStorage.AllocationID); }