orbit
orbit copied to clipboard
Investigate the use of some level of snapshot testing
Something along the lines should work but we need to find a way to wrap it up nicely for use:
[Test]
public void SceneShouldRenderAsExpected()
{
var scenery = new Scenery();
var canvas = new SkiaCanvas();
var bitmap = new SKBitmap(new SKImageInfo(1000, 1000));
canvas.Canvas = new SKCanvas(bitmap);
// Test our Render implementation
scenery.Render(canvas, new Microsoft.Maui.Graphics.RectF(0, 0, 1000, 1000));
using var stream = File.Create("snapshot.png");
bitmap.Encode(stream, SKEncodedImageFormat.Png, 100);
}
public class Scenery : GameScene
{
public override void Render(Canvas canvas, RectF dimensions)
{
base.Render(canvas, dimensions);
canvas.FillColor = Colors.PaleGoldenrod;
canvas.FillRectangle(new Rect(0, 0, 100, 100));
}
}
This currently just involves a GameScene
implementation that simply draws a rectangle on screen.