public async Task Render_DebugLayer() { await TestUtilities.InitializeWithGraphicsAsync(); using (var debugLayer = new DebugDrawingLayer()) using (var memRenderTarget = new MemoryRenderTarget(1024, 1024)) { // Perform rendering memRenderTarget.ClearColor = Color4.CornflowerBlue; await memRenderTarget.RenderLoop.Register2DDrawingLayerAsync(debugLayer); await memRenderTarget.AwaitRenderAsync(); // Take screenshot var screenshot = await memRenderTarget.RenderLoop.GetScreenshotGdiAsync(); // TestUtilities.DumpToDesktop(screenshot, "Blub.png"); // Calculate and check difference var diff = BitmapComparison.CalculatePercentageDifference( screenshot, TestUtilities.LoadBitmapFromResource("Drawing2D", "DebugDrawingLayer.png")); Assert.IsTrue(diff < 0.2, "Difference to reference image is to big!"); } }
public async Task Render_DebugLayer() { await UnitTestHelper.InitializeWithGrahicsAsync(); using (DebugDrawingLayer debugLayer = new DebugDrawingLayer()) using (MemoryRenderTarget memRenderTarget = new MemoryRenderTarget(1024, 1024)) { // Perform rendering memRenderTarget.ClearColor = Color4.CornflowerBlue; await memRenderTarget.RenderLoop.Register2DDrawingLayerAsync(debugLayer); await memRenderTarget.AwaitRenderAsync(); // Take screenshot GDI.Bitmap screenshot = await memRenderTarget.RenderLoop.GetScreenshotGdiAsync(); //screenshot.DumpToDesktop("Blub.png"); // Calculate and check difference float diff = BitmapComparison.CalculatePercentageDifference( screenshot, Properties.Resources.ReferenceImage_DebugDawingLayer); Assert.True(diff < 0.2, "Difference to reference image is to big!"); } }