I'm calling my backdoor method via my tests. Somehow in my AppDelegate.cs it causes the Xamarin test to crash and have an exception error:
System.Exception: Error while performing Invoke("nameMethod", null)
--> System.Net.WebException : Error getting response stream (ReadDone 2): ReceiveFailure
--> System.Exception: at System.Net.WebConnection.HandleError(WebExceptionStatus st, System.Exception e, System.String where)
at System.Net.WebConnection.ReadDone(IAsyncResult result)
My AppDelegate backdoor method is:
[Export ("getPageTitle:")]
public NSString GetPageTitle (NSString s)
{
Page page = App.Current.MainPage; //somehow I narrowed down to this line, this crashes the whole thing
if (page != null)
{
return new NSString(page.Title);
}
return new NSString("No page found");
}
My call:
[Test()]
public void SomeMethod()
{
app.Invoke("getPageTitle");
}
Is it not possible to get the App context here? What am I doing wrong?