hi all
I want write unit test for navigate to Mastedetail Page from my LoginViewModel
My case is:
Application.Current.MainPage.Navigation.PushModalAsync(new MainPage());
here my MainPage is Masterdetai Page and here if write Unit Test case like this
[Test]
public async Task Test1()
{
var lvm = new LoginViewModel();
lvm.Username = "admin";
lvm.Password = "admin";
var app = new App();
var page = new ContentPage();
Application.Current.MainPage = new MainPage();
await Application.Current.MainPage.Navigation.PushModalAsync(page1);
string result = lvm.LoginResult();
Assert.IsTrue(result == "Success", "test fail");
Assert.Pass();
}
its giving System.InvalidOperationException: You MUST call Xamarin.Forms.Init(); prior to using it, error at master detail page line MasterBehavior = MasterBehavior.Popover;
if any one have idea please let me know how to get Application.current.mainpage in unit test project and how to resolve this issue
Thanks In Advance