Esempio n. 1
0
            public void PropertyVisitor_VisitingAStructWithPrimitiveProperties_DoesNotAllocate()
            {
                var container = new StructWithPrimitiveProperties();
                var visitor   = new CountVisitor();

                GCAllocTest.Method(() =>
                {
                    visitor.Count = 0;
                    PropertyContainer.Visit(ref container, visitor);
                })
                .ExpectedCount(0)
                .Warmup()
                .Run();

                Assert.That(visitor.Count, Is.EqualTo(2));
            }
Esempio n. 2
0
            public void PropertyVisitor_VisitingAnEmptyClass_DoesNotAllocate()
            {
                var container = new EmptyClass();
                var visitor   = new CountVisitor();

                GCAllocTest.Method(() =>
                {
                    visitor.Count = 0;
                    PropertyContainer.Accept(visitor, ref container);
                })
                .ExpectedCount(0)
                .Warmup()
                .Run();

                Assert.That(visitor.Count, Is.EqualTo(0));
            }
Esempio n. 3
0
            public void PropertyVisitor_VisitingAClassWithCollectionProperties_DoesNotAllocate()
            {
                var container = new ClassWithCollectionProperties
                {
                    Float32List = new List <float> {
                        1, 2, 3
                    }
                };
                var visitor = new CountVisitor();

                GCAllocTest.Method(() =>
                {
                    visitor.Count = 0;
                    PropertyContainer.Visit(ref container, visitor);
                })
                .ExpectedCount(0)
                .Warmup()
                .Run();

                Assert.That(visitor.Count, Is.EqualTo(4));
            }