https://github.com/thomasgalliker/mauimocks
Library for running Microsoft.Maui inside of unit tests
https://github.com/thomasgalliker/mauimocks
maui mauimocks mocks testing unittest
Last synced: 12 months ago
JSON representation
Library for running Microsoft.Maui inside of unit tests
- Host: GitHub
- URL: https://github.com/thomasgalliker/mauimocks
- Owner: thomasgalliker
- License: mit
- Created: 2024-04-20T09:11:47.000Z (about 2 years ago)
- Default Branch: develop
- Last Pushed: 2025-04-29T15:17:12.000Z (about 1 year ago)
- Last Synced: 2025-06-20T01:49:04.259Z (12 months ago)
- Topics: maui, mauimocks, mocks, testing, unittest
- Language: C#
- Homepage:
- Size: 78.1 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
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:
```bash
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:
```csharp
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](https://github.com/thomasgalliker/MauiMocks/issues).