Skip to main content
net8.0

Library for running Microsoft.Maui inside of unit tests

Published
Apr 22, 2024
2y ago
Total Downloads
39.3K
39,303

Install

dotnet add package Mocks.Maui --version 1.1.2-pre
ProductVersions
.NET
net8.0

README

MauiMocks

MauiMocks facilitates service mocking in unit tests for .NET MAUI test projects.

Download and Installation

This library is available on NuGet: https://www.nuget.org/packages/Mocks.Maui To install MauiMocks via NuGet package manager console, use the following command:

PM> Install-Package Mocks.Maui

This library is compatible with any .NET MAUI test project running on .NET 8 and newer.

API Usage

While many UI classes in a .NET MAUI project are readily usable in unit tests, certain classes rely on services registered in the DI container or initialized during app startup. MauiMocks aids in mocking all essential services from .NET MAUI, enabling unit test execution without the need to fully deploy the app on a device/simulator.

Initializing MauiMocks

In the setup section of your unit test, execute the following code to prepare .NET MAUI for testing:

MauiMocks.Init();

Ensure that unit tests utilizing this code are not executed concurrently, as this may lead to unpredictable outcomes.

Issues & Inquiries

If you encounter a bug or wish to propose a new feature, please feel free to do so by opening a new issue here.

Changes from Previous Version

No structural changes between v1.1.1-pre and v1.1.2-pre.

Adoption Assessment

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

This version is marked prerelease. Validate its API and upgrade path before production use.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.