Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate the use of some level of snapshot testing #12

Open
bijington opened this issue Jul 14, 2022 · 0 comments
Open

Investigate the use of some level of snapshot testing #12

bijington opened this issue Jul 14, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@bijington
Copy link
Owner

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.

@bijington bijington added the enhancement New feature or request label Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant