Evergine.Mocks 2022.9.28.2

dotnet add package Evergine.Mocks --version 2022.9.28.2
NuGet\Install-Package Evergine.Mocks -Version 2022.9.28.2
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="2022.9.28.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Evergine.Mocks --version 2022.9.28.2
#r "nuget: Evergine.Mocks, 2022.9.28.2"
#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=2022.9.28.2

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

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 net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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
2022.9.28.2 1,490 7/18/2023
2022.9.28.1 208 1/11/2023

- add fixed game time
It is a must to provide a fixed game time in MockWindowSystem.RunOneLoop() in order to make tests more deterministic.
- fix Camera3D.AspectRatio -1
The camera is updated now with the display settings, retrieving the correct screen size.