public void Test() { //Attach! //Use Visual Studio. using (var app = new UWPAppFriend(new ByVisualStudio(Path.GetFullPath("../../../TargetApp/TargetApp.sln")) { VisualStudioPath = @"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe", ChangeVisualStudioSetting = (vs, dteSrc) => { var dte = dteSrc.Pin <DTE2>(); dte.Solution.SolutionBuild.SolutionConfigurations.Item(3).Activate(); }, ContinueDebuging = true, InjectionBreakPoint = "App.OnLaunched", Uri = "http://localhost:8085/" })) { // get mainpage. var current = app.Type("Windows.UI.Xaml.Window").Current; var mainPage = current.Content.Content; //invoke method. string ret = mainPage.Func(10); Assert.AreEqual("10", ret); //change color. var color = app.Type("Windows.UI.Colors").Blue; var brush = app.Type("Windows.UI.Xaml.Media.SolidColorBrush")(color); mainPage.Content.Background = brush; } }
public void Test() { using (var app = new UWPAppFriend(new ByVisualStudio(Path.GetFullPath("../../../TargetApp/TargetApp.sln")) { VisualStudioPath = @"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe", ChangeVisualStudioSetting = (vs, dteSrc) => { var dte = dteSrc.Pin <DTE2>(); dte.Solution.SolutionBuild.SolutionConfigurations.Item(3).Activate(); } })) { //get visual tree. var tree = app.CurrentWindow.Content.VisualTree(); //textbox var textBox = new TextBox(tree.ByType(TextBox.TypeFullName).Single()); textBox.EmulateChangeText("abc"); //button var button = new Button(tree.ByBinding("Execute").Single()); button.EmulateClick(); //combobox var comboBox = new ComboBox(tree.ByType(ComboBox.TypeFullName).Single()); comboBox.EmulateChangeSelectedIndex(2); //listbox var listBox = new ListBox(tree.ByType(ListBox.TypeFullName).Single()); listBox.EmulateChangeSelectedIndex(2); //radiobutton var radioButton = new RadioButton(tree.ByType(RadioButton.TypeFullName).Single()); radioButton.EmulateCheck(true); //check button var check = new CheckBox(tree.ByType(CheckBox.TypeFullName).Single()); check.EmulateCheck(true); //it can access all .net api //var mainPage = Windows.UI.Xaml.Window.Current.Content.Content; var mainPage = app.Type("Windows.UI.Xaml.Window").Current.Content.Content; //invoke method defined by user. string result = mainPage.MyFunc(5); Assert.AreEqual("5", result); //change color var color = app.Type("Windows.UI.Colors").Blue; var brush = app.Type("Windows.UI.Xaml.Media.SolidColorBrush")(color); mainPage.Content.Background = brush; } }