Evergine.Mocks
2022.9.28.2
See the version list below for details.
dotnet add package Evergine.Mocks --version 2022.9.28.2
NuGet\Install-Package Evergine.Mocks -Version 2022.9.28.2
<PackageReference Include="Evergine.Mocks" Version="2022.9.28.2" />
paket add Evergine.Mocks --version 2022.9.28.2
#r "nuget: Evergine.Mocks, 2022.9.28.2"
// 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
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 | Versions 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. |
-
net6.0
- Evergine.Common (>= 2022.9.28.1)
- Evergine.Framework (>= 2022.9.28.1)
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 | 255 | 12/3/2024 |
2022.9.28.2 | 4,007 | 7/18/2023 |
2022.9.28.1 | 239 | 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.