Exemplo n.º 1
0
        public void FreeInMemoryObjects_LazinatorList()
        {
            var typical1 = GetTypicalExample();

            typical1.SerializeLazinator();
            var typical2              = GetTypicalExample();
            var origValue             = typical2.MyChild1.MyLong;
            LazinatorList <Example> l = new LazinatorList <Example>()
            {
                typical1, typical2
            };

            l.SerializeLazinator();
            l.FreeInMemoryObjects();
            typical2.MyChild1.MyLong = 46523496; // should not affect the list now
            l[0].MyChild1.MyLong.Should().Be(origValue);
            l[1].MyChild1.MyLong.Should().Be(origValue);

            const long revisedValue = -123456789012345;

            l[0].MyChild1.MyLong = revisedValue;
            l.SerializeLazinator();
            l.FreeInMemoryObjects();
            l[0].MyChild1.MyLong.Should().Be(revisedValue);
            l[1].MyChild1.MyLong.Should().Be(origValue);
        }
Exemplo n.º 2
0
        public void LazinatorListDirtinessWithNestedStructs()
        {
            LazinatorList <ExampleStructContainingStruct> l = new LazinatorList <ExampleStructContainingStruct>()
            {
                new ExampleStructContainingStruct()
                {
                    MyExampleStructContainingClasses = new ExampleStructContainingClasses()
                    {
                        MyChar = 'Q'
                    }
                }
            };

            l.SerializeLazinator();
            var c = l.CloneLazinatorTyped();

            // consider original list, which should be clean
            l.IsDirty.Should().BeFalse();
            l.DescendantIsDirty.Should().BeFalse();
            l[0].IsDirty.Should().BeFalse();
            l[0].MyExampleStructContainingClasses.IsDirty.Should().BeFalse();
            // now consider clone
            c.IsDirty.Should().BeFalse();
            c.DescendantIsDirty.Should().BeFalse();
            c[0].IsDirty.Should().BeFalse();
            c[0].MyExampleStructContainingClasses.IsDirty.Should().BeFalse();
            c[0].MyExampleStructContainingClasses.MyChar.Should().Be('Q');
        }
Exemplo n.º 3
0
        public void CanCloneListOfLazinatorsAndThenEnsureUpToDate()
        {
            var l = new LazinatorList <Example>()
            {
                GetTypicalExample(), GetTypicalExample()
            };
            var l2 = l.CloneLazinatorTyped();
            var l3 = l.CloneLazinatorTyped();

            l.SerializeLazinator();
        }
Exemplo n.º 4
0
        public void CanCloneListOfStructsAndThenEnsureUpToDate()
        {
            // Note: This works because of IsStruct parameter in ReplaceBuffer. Without that parameter, the last call would lead to disposal of memory still needed.
            var l = new LazinatorList <WInt32>()
            {
                1
            };
            var l2 = l.CloneLazinatorTyped();
            var l3 = l.CloneLazinatorTyped();

            l.SerializeLazinator();
        }
Exemplo n.º 5
0
        public void LazinatorListDirtinessWithStructs()
        {
            LazinatorList <WInt32> l = new LazinatorList <WInt32>()
            {
                new WInt32(3)
            };

            l.SerializeLazinator();
            var c = l.CloneLazinatorTyped();

            // consider original list, which should be clean
            l.IsDirty.Should().BeFalse();
            l.DescendantIsDirty.Should().BeFalse();
            l[0].IsDirty.Should().BeFalse();
            // now consider clone
            c.IsDirty.Should().BeFalse();
            c.DescendantIsDirty.Should().BeFalse();
            c[0].IsDirty.Should().BeFalse();
        }