I\'m creating an application using Prism and Xamarin Forms. I want to unit-test my view models.
I have a command that navigate to a page. I want to assert that the n
What you are proposing is to unit test Prism not your code. Unit testing your ViewModel is a good thing, but you only need to provide a Mock that provides you a way to verify that the navigation string/parameters you expected were valid. For example your Mock may look something like:
public class MockNavigationService : INavigationService
{
public string LastNavigationString { get; private set; }
public NavigationParameters LastNavigationParameters { get; private set; }
public Task NavigateAsync(string name, NavigationParameters parameters, bool? useModalNavigation = null, bool animated = true)
{
LastNavigationString = name;
LastNavigationParameters = parameters;
return Task.FromResult(0);
}
}
What it sounds like to me is that what your real goal is though is not to run a unit test but to do a UITest that could validate the navigation and User experience with your application.