-
Book Overview & Buying
-
Table Of Contents
.NET MAUI Cross-Platform Application Development - Second Edition
By :
In developing unit tests for .NET MAUI, we will present test case development for both XAML-based and Blazor-based apps. In both instances, we will incorporate the MVVM pattern in the design. The unit test cases at the model layer are identical for both; however, testing the view and the view model differs significantly. Developing unit test cases for the view and the view model in a XAML-based app can be quite complex. To test the view model, it is necessary to resolve the dependencies of XAML components. For instance, in the XAML version of our app, we need to invoke Shell navigation methods within the view model, as demonstrated in the following code:
await Shell.Current.GoToAsync(
$"{nameof(ItemsPage)}?{nameof(ItemsViewModel.ItemId)}={item
.Id}");
To address dependencies in Xamarin.Forms, an open-source project, Xamarin.Forms.Mocks, is available to help mock Xamarin.Forms components. In the case of .NET MAUI XAML apps, we require...