EvaluateAsync() public method

public EvaluateAsync ( string rScript ) : Task
rScript string
return Task
Exemplo n.º 1
0
        public async Task TruncateGrandChildrenTest()
        {
            await _hostScript.EvaluateAsync("x.truncate.children<-1:100");

            var children = await _hostScript.GlobalEnvrionment.GetChildrenAsync();

            var child = children.First(c => c.Name == "x.truncate.children");

            var grandChildren = await child.GetChildrenAsync();

            grandChildren.Count.Should().Be(21);   // truncate 20 + ellipsis
            grandChildren[20].Value.Should().Be(Resources.VariableExplorer_Truncated);
        }
Exemplo n.º 2
0
        public void VariableGrid_ConstructorTest02() {
            VisualTreeObject actual = null;
            using (var hostScript = new VariableRHostScript()) {
                using (var script = new ControlTestScript(typeof(VariableGridHost))) {
                    DoIdle(100);

                    EvaluationWrapper wrapper = null;
                    Task.Run(async () => {
                        hostScript.VariableProvider.Subscribe(
                            0,
                            "grid.test",
                            (r) => wrapper = new EvaluationWrapper(r));

                        await hostScript.EvaluateAsync("grid.test <- matrix(1:10, 2, 5)");
                    }).Wait();

                    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");
        }
Exemplo n.º 3
0
        public async Task DoesNotExist()
        {
            // This is the equivalent of what we get when we fetch a variable
            // for a data grid after that variable is no longer available (rm or reset).
            var script = "idonotexist";

            using (var hostScript = new VariableRHostScript()) {
                var evaluationResult = await hostScript.EvaluateAsync(script);

                evaluationResult.Name.Should().BeNull();
                evaluationResult.Expression.Should().Be("idonotexist");

                var model = new VariableViewModel(evaluationResult, null);
                model.TypeName.Should().BeNull();
                model.Value.Should().BeNull();
            }
        }
Exemplo n.º 4
0
        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.ExportProvider.GetExportedValue<IObjectDetailsViewerAggregator>());

            DoIdle(2000);

            wrapper.Should().NotBeNull();

            UIThreadHelper.Instance.Invoke(() => {
                var host = (VariableGridHost)script.Control;
                host.SetEvaluation(wrapper);
            });

            DoIdle(1000);
        }
        public async Task TruncateGrandChildrenTest() {
            using (var hostScript = new VariableRHostScript()) {
                await hostScript.EvaluateAsync("x.truncate.children<-1:100");
                var children = await hostScript.GlobalEnvrionment.GetChildrenAsync();
                var child = children.First(c => c.Name == "x.truncate.children");

                var grandChildren = await child.GetChildrenAsync();

                grandChildren.Count.ShouldBeEquivalentTo(21);   // truncate 20 + ellipsis
                grandChildren[20].Value.ShouldBeEquivalentTo(Resources.VariableExplorer_Truncated);
            }
        }