Evergine.Mocks 2024.10.24.1

dotnet add package Evergine.Mocks --version 2024.10.24.1                
NuGet\Install-Package Evergine.Mocks -Version 2024.10.24.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Evergine.Mocks" Version="2024.10.24.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Evergine.Mocks --version 2024.10.24.1                
#r "nuget: Evergine.Mocks, 2024.10.24.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Evergine.Mocks as a Cake Addin
#addin nuget:?package=Evergine.Mocks&version=2024.10.24.1

// Install Evergine.Mocks as a Cake Tool
#tool nuget:?package=Evergine.Mocks&version=2024.10.24.1                

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)
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2024.10.24.1 265 12/3/2024
2022.9.28.2 4,017 7/18/2023
2022.9.28.1 239 1/11/2023

- update Evergine references to 2024.10.24.804 (and .NET 8.0)