public async Task SortTest02() { VisualTreeObject actual = null; using (var hostScript = new VariableRHostScript()) { using (var script = new ControlTestScript(typeof(VariableGridHost))) { await PrepareControl(hostScript, script, "grid.test <- mtcars"); await UIThreadHelper.Instance.InvokeAsync(async() => { var grid = await VisualTreeExtensions.FindChildAsync <VisualGrid>(script.Control); var header = await VisualTreeExtensions.FindChildAsync <HeaderTextVisual>(script.Control); // mpg header = await VisualTreeExtensions.FindNextSiblingAsync <HeaderTextVisual>(header); // cyl header.Should().NotBeNull(); grid.ToggleSort(header, false); DoIdle(200); header = await VisualTreeExtensions.FindNextSiblingAsync <HeaderTextVisual>(header); // disp header = await VisualTreeExtensions.FindNextSiblingAsync <HeaderTextVisual>(header); // hp grid.ToggleSort(header, add: true); grid.ToggleSort(header, add: true); DoIdle(200); }); actual = VisualTreeObject.Create(script.Control); ViewTreeDump.CompareVisualTrees(_files, actual, "VariableGridSorted02"); } } }
public async Task VariableGrid_ConstructorTest() { VisualTreeObject actual = null; using (var hostScript = new VariableRHostScript()) { using (var script = new ControlTestScript(typeof(VariableGridHost))) { DoIdle(100); var result = await hostScript.EvaluateAsync("grid.test <- matrix(1:10, 2, 5)"); VariableViewModel wrapper = new VariableViewModel(result, VsAppShell.Current.ExportProvider.GetExportedValue <IObjectDetailsViewerAggregator>()); DoIdle(2000); wrapper.Should().NotBeNull(); UIThreadHelper.Instance.Invoke(() => { var host = (VariableGridHost)script.Control; host.SetEvaluation(wrapper); }); DoIdle(1000); actual = VisualTreeObject.Create(script.Control); ViewTreeDump.CompareVisualTrees(_files, actual, "VariableGrid02"); } } }
public void FetchDataErrors02() { using (var script = new VariableRHostScript()) { ExcelData xlData = ExcelInterop.GenerateExcelData("zzzzzz", 2, 2); xlData.Should().BeNull(); } }
public async Task VariableGrid_ConstructorTest02() { VisualTreeObject actual = null; using (var hostScript = new VariableRHostScript()) { using (var script = new ControlTestScript(typeof(VariableGridHost))) { DoIdle(100); var result = await hostScript.EvaluateAsync("grid.test <- matrix(1:10, 2, 5)"); EvaluationWrapper wrapper = new EvaluationWrapper(result); DoIdle(2000); wrapper.Should().NotBeNull(); UIThreadHelper.Instance.Invoke(() => { var host = (VariableGridHost)script.Control; host.SetEvaluation(wrapper); }); DoIdle(1000); actual = VisualTreeObject.Create(script.Control); ViewTreeDump.CompareVisualTrees(_files, actual, "VariableGrid02"); } } }
public VariableGridTest(TestFilesFixture files) { _files = files; var workflow = VsAppShell.Current.ExportProvider.GetExportedValue <IRInteractiveWorkflowProvider>().GetOrCreate(); _hostScript = new VariableRHostScript(SessionProvider); }
public async Task ConstructorTest() { VisualTreeObject actual = null; using (var hostScript = new VariableRHostScript()) { using (var script = new ControlTestScript(typeof(VariableGridHost))) { await PrepareControl(hostScript, script, "grid.test <- matrix(1:10, 2, 5)"); actual = VisualTreeObject.Create(script.Control); ViewTreeDump.CompareVisualTrees(_files, actual, "VariableGrid02"); } } }
private async Task <IRSessionDataObject> GetMtCars(VariableRHostScript script) { var sessionProvider = VsAppShell.Current.ExportProvider.GetExportedValue <IRSessionProvider>(); var session = sessionProvider.GetInteractiveWindowRSession(); using (var e = await session.BeginInteractionAsync()) { await e.RespondAsync("x <- mtcars" + Environment.NewLine); } await script.EvaluateAsync("x" + Environment.NewLine); IReadOnlyList <IRSessionDataObject> vars = await script.GlobalEnvrionment.GetChildrenAsync(); return(vars.FirstOrDefault(x => x.Name == "x")); }
private async Task PrepareControl(VariableRHostScript hostScript, ControlTestScript script, string expression) { DoIdle(100); var result = await hostScript.EvaluateAsync(expression); VariableViewModel wrapper = new VariableViewModel(result, VsAppShell.Current.Services); DoIdle(2000); wrapper.Should().NotBeNull(); UIThreadHelper.Instance.Invoke(() => { var host = (VariableGridHost)script.Control; host.SetEvaluation(wrapper); }); DoIdle(1000); }
public async Task FetchData() { using (var script = new VariableRHostScript()) { var o = await GetMtCars(script); o.Should().NotBeNull(); ExcelData xlData = ExcelInterop.GenerateExcelData("x", o.Dimensions[0], o.Dimensions[1]); int rows = o.Dimensions[0]; int cols = o.Dimensions[1]; xlData.CellData.GetLength(0).Should().Be(rows); xlData.CellData.GetLength(1).Should().Be(cols); xlData.RowNames.Length.Should().Be(rows); xlData.ColNames.Length.Should().Be(cols); xlData.CellData[0, 0].Should().Be("21.0"); xlData.CellData[rows - 1, cols - 1].Should().Be("2"); } }
public async Task SortTest01() { VisualTreeObject actual = null; using (var hostScript = new VariableRHostScript()) { using (var script = new ControlTestScript(typeof(VariableGridHost))) { await PrepareControl(hostScript, script, "grid.test <- matrix(1:10, 2, 5)"); var header = VisualTreeTestExtensions.FindFirstVisualChildOfType <HeaderTextVisual>(script.Control); var grid = VisualTreeTestExtensions.FindFirstVisualChildOfType <VisualGrid>(script.Control); header.Should().NotBeNull(); await UIThreadHelper.Instance.InvokeAsync(() => { grid.ToggleSort(header, false); DoIdle(200); grid.ToggleSort(header, false); }); DoIdle(200); actual = VisualTreeObject.Create(script.Control); ViewTreeDump.CompareVisualTrees(_files, actual, "VariableGridSorted01"); } } }
public VariableGridTest(TestFilesFixture files) { _files = files; _hostScript = new VariableRHostScript(SessionProvider); }
public VariableGridTest(IServiceContainer services, TestFilesFixture files) : base(services) { _files = files; _hostScript = new VariableRHostScript(Services); }
public VariableGridTest(TestFilesFixture files, BrokerFixture broker) { _files = files; _broker = broker; _hostScript = new VariableRHostScript(SessionProvider, _broker.BrokerConnector); }