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)); }
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)); }
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)); }