Skip to content

Instantly share code, notes, and snippets.

@ChaseFlorell
Last active June 2, 2016 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChaseFlorell/5a3a627e3f0a688fe61476785a7b7232 to your computer and use it in GitHub Desktop.
Save ChaseFlorell/5a3a627e3f0a688fe61476785a7b7232 to your computer and use it in GitHub Desktop.
Fugly back doors for Xamarin Forms + UITest
app.Invoke("Backdoor", "MyActualMethod")
[Activity(Label = "my.activity",
MainLauncher = true,
ScreenOrientation = ScreenOrientation.Portrait)]
public sealed class MainActivity : Activity
{
public MainActivity()
{
Backdoors = new Dictionary<string, Func<string>>();
}
public static Dictionary<string, Func<string>> Backdoors { get; internal set; }
[Export("Backdoor")]
public string Backdoor(string actualMethod)
{
return Backdoors[actualMethod].Invoke();
}
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// bla
}
}
public class MyCustomRenderer : SomeRenderer{
public MyCustomRenderer(){
MainActivity.Backdoors.Add("MyActualMethod", MyActualMethod);
}
public string MyActualMethod(){
return "foo bar";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment