示例#1
0
        public async Task PackageDescriptionTest()
        {
            RToolsSettings.Current = new TestRToolsSettings();
            PackageIndex packageIndex;

            using (var host = new IntelliSenseRSession(_shell, _sessionProvider, _workflowProvider)) {
                await host.CreateSessionAsync();

                var functionIndex = new FunctionIndex(_shell, null, host);
                packageIndex = new PackageIndex(_shell, host, functionIndex);
                await packageIndex.BuildIndexAsync();
            }
            IPackageInfo pi = await packageIndex.GetPackageInfoAsync("base");

            pi.Description.Should().Be("Base R functions.");
        }
示例#2
0
        public async Task InstallPackageTest()
        {
            await Workflow.RSession.EnsureHostStartedAsync(new RHostStartupInfo(), null, 50000);

            var completionSets = new List <CompletionSet>();

            for (int i = 0; i < 2; i++)
            {
                try {
                    await Workflow.Packages.UninstallPackageAsync("abc", null);

                    EventsPump.DoEvents(1000);
                } catch (RException) { }

                await PackageIndex.BuildIndexAsync();

                completionSets.Clear();
                RCompletionTestUtilities.GetCompletions(Services, "abc::", 5, completionSets);

                completionSets.Should().ContainSingle();
                // Try again one more time
                if (completionSets[0].Completions.Count == 0)
                {
                    break;
                }
            }
            completionSets[0].Completions.Should().BeEmpty();

            try {
                await Workflow.RSession.ExecuteAsync("install.packages('abc')", REvaluationKind.Mutating);

                EventsPump.DoEvents(1000);
            } catch (RException) { }

            await PackageIndex.BuildIndexAsync();

            completionSets.Clear();
            RCompletionTestUtilities.GetCompletions(Services, "abc::", 5, completionSets);

            completionSets.Should().ContainSingle();
            completionSets[0].Completions.Should().NotBeEmpty();
        }
        public async Task <IEditorScript> StartScript(ICoreShell coreShell, string text, string filename, string contentType, IRSessionProvider sessionProvider)
        {
            var coreEditor = await InUI(() => new CoreEditor(coreShell, text, filename, contentType));

            var containerDisposable = await AddToHost(coreEditor.Control);

            if (sessionProvider != null)
            {
                IntelliSenseRSession.HostStartTimeout = 10000;
                HostScript = new RHostScript(sessionProvider);

                PackageIndex = coreShell.GetService <IPackageIndex>();
                await PackageIndex.BuildIndexAsync();

                FunctionIndex = coreShell.GetService <IFunctionIndex>();
                await FunctionIndex.BuildIndexAsync();
            }

            return(new EditorScript(coreShell, coreEditor, containerDisposable));
        }
示例#4
0
        public async Task InstallPackageTest()
        {
            using (var script = new RHostScript(Workflow.RSessions)) {
                var completionSets = new List <CompletionSet>();
                for (int i = 0; i < 2; i++)
                {
                    try {
                        await script.Session.ExecuteAsync("remove.packages('abc')", REvaluationKind.Mutating);
                    } catch (RException) { }

                    await PackageIndex.BuildIndexAsync();

                    completionSets.Clear();
                    GetCompletions("abc::", 5, completionSets);

                    completionSets.Should().ContainSingle();
                    // Try again one more time
                    if (completionSets[0].Completions.Count == 0)
                    {
                        break;
                    }
                }
                completionSets[0].Completions.Should().BeEmpty();

                try {
                    await script.Session.ExecuteAsync("install.packages('abc')", REvaluationKind.Mutating);
                } catch (RException) { }

                await PackageIndex.BuildIndexAsync();

                completionSets.Clear();
                GetCompletions("abc::", 5, completionSets);

                completionSets.Should().ContainSingle();
                completionSets[0].Completions.Should().NotBeEmpty();
            }
        }