[Enhancement] Is there a version planned for .NET MAUI?
Hello @jonathanpeppers,
first of all, thank you for writing this tool. It helps us a lot when we write component and integration tests.
Is there a plan to have a similar tool for .NET MAUI? I haven't figured out how to write it myself. At least until now.
I hadn't planned on doing anything here yet.
It might be possible to do it yourself already, you can look at MAUI's tests and copy what they do?
This is just a random example:
https://github.com/dotnet/maui/blob/main/src/Controls/tests/Core.UnitTests/ContentViewUnitTest.cs
https://github.com/jonathanpeppers/Xamarin.Forms.Mocks/pull/72
In case it helps anyone else as it did for some of my unit tests. This worked when I wanted to check some code that did things with resource dictionaries in App.Current and I had this in my test constructor (I previously also used this NuGet package in the constructor):
public ExampleTest()
{
Application.Current = new App();
}
Update your App.xaml.cs like to get the above test code to work.
public partial class App : Application
{
public App()
{
#if ANDROID || MACCATALYST || IOS || WINDOWS
// don't call InitializeComponent in unit tests
InitializeComponent();
#endif
}
#if NET7_0_OR_GREATER && !ANDROID && !MACCATALYST && !IOS && !WINDOWS
// workaround for unit tests in Maui https://github.com/dotnet/maui/issues/3552#issuecomment-1172606125
public static void Main(string[] args) {}
#endif
}