Skip to main content
net8.0

Library to enable testing applications made with Evergine.

Published
Dec 3, 2024
1y ago
Total Downloads
14.1K
14,134

Install

dotnet add package Evergine.Mocks --version 2024.10.24.1
ProductVersions
.NET
net8.0

README

Evergine.Mocks

Tests status Nuget

Introduction

Library to enable testing applications made with Evergine, inspired on Xamarin.Forms.Mocks.

Goals:

  • Enable testing components and behaviors

Out of scope:

  • Enable testing drawables or anything related to rendering

Approach

The most of our applications contain a bunch of components (it-self, or behaviors/drawables) which contain logic. Such components, usually, consume other artifacts from outside:

  • other components
  • services
  • managers
  • entities from its hierarchy

Beacause of this, isolating a component for testing is quite complicated. However, we can rely on a mock Windows System which, in a headless fashion, replicates the same behavior the app would have.

Status

  • running single update-draw loop on demand
  • reading actual Content
  • BindComponent attribute
  • BindService attribute
  • Camera3D.Display
  • mock KeyboardDispatcher
  • mock MouseDispatcher
  • mock TouchDispatcher

Changes needed in our projects

  • Leave Application.Initialize() empty: refactor its entire logic into a separate public method, called from each WindowsSystem
    • This is needed to avoid tests to set the ScreenContext up and navigate to an actual Scene by default
windowsSystem.Run(
    () =>
    {
        // Pull initialization logic from here...
        application.Initialize();
        // to here
        application.NavigateToMainScene();
    },
    () =>
    {
        [...]
    });
  • Execute tests sequentially: Evergine currently does not support running tests in parallel
    • You can see how to do it with xUnit here

Changes needed in Evergine

  • New GraphicsBackend value: Mock, None, Test
  • Maybe: Allow running tests in parallel (it seems there are some static references preventing such)

Changes from Previous Version

v2022.9.28.2v2024.10.24.1
Added Frameworks
net8.0
Removed Frameworks
net6.0
Added Dependencies
Removed Dependencies

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

No SPDX license expression is published. Review the license text and your organisation's policy before redistribution.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.