using Azimuth; using UnitTestSharp; using Blacklight.Core.Drawables; namespace Blacklight.Core.UnitTests { public class WindowHandleTests : TestFixture { public class VisitAllocationTests : TestFixture { private NullWindowHandle _windowHandle; private Collage _collage; private Sprite _sprite; private BorderPolygon _borderPolygon; private Polygon _polygon; private ClosedQuadraticBezierCurve _closedCurve; public override void TestSetup() { _windowHandle = new NullWindowHandle(); _collage = new Collage(); _sprite = new Sprite(); _borderPolygon = new BorderPolygon( new Vector[] { new Vector(0, 0), new Vector(4, 0), new Vector(0, 3) }); _polygon = new Polygon(new Vector[] { new Vector(0, 0), new Vector(5, 0), new Vector(1, 4) }); _closedCurve = new ClosedQuadraticBezierCurve(new Vector[] { new Vector(0, 0), new Vector(-5, 0), new Vector(-10, 10), new Vector(0, 7), new Vector(10, 10), new Vector(5, -5), }); } [AllocationTest] public void Rectangle_AllocatesNothingOnceWarm() { _windowHandle.Visit(new Entity(new Rectangle(), AffineMatrix.Identity)); CheckNoAllocations(); } [AllocationTest] public void Ellipse_AllocatesNothingOnceWarm() { _windowHandle.Visit(new Entity(new Ellipse(), AffineMatrix.Identity)); CheckNoAllocations(); } [AllocationTest] public void BorderTriangle_AllocatesNothingOnceWarm() { _windowHandle.Visit(new Entity(new BorderTriangle(), AffineMatrix.Identity)); CheckNoAllocations(); } [AllocationTest] public void QuadraticBezierTriangle_AllocatesNothingOnceWarm() { _windowHandle.Visit( new Entity(new QuadraticBezierTriangle(), AffineMatrix.Identity)); CheckNoAllocations(); } [AllocationTest] public void Sprite_AllocatesNothingOnceWarm() { _windowHandle.Visit(new Entity(_sprite, AffineMatrix.Identity)); CheckNoAllocations(); } [AllocationTest] public void BorderPolygon_AllocatesNothingOnceWarm() { _windowHandle.Visit(new Entity(_borderPolygon, AffineMatrix.Identity)); CheckNoAllocations(); } [AllocationTest] public void Polygon_AllocatesNothingOnceWarm() { _windowHandle.Visit(new Entity(_polygon, AffineMatrix.Identity)); CheckNoAllocations(); } [AllocationTest] public void ClosedQuadraticBezierCurve_AllocatesNothingOnceWarm() { _windowHandle.Visit(new Entity(_closedCurve, AffineMatrix.Identity)); CheckNoAllocations(); } [AllocationTest] public void Collage_AllocatesNothingOnceWarm() { _windowHandle.Visit(new Entity(_collage, AffineMatrix.Identity)); CheckNoAllocations(); } } } }