コード例 #1
0
        public async Task InstallAndUninstallPackageSpecifiedLib()
        {
            var interactiveWindowComponentContainerFactory = _exportProvider.GetExportedValue <IInteractiveWindowComponentContainerFactory>();

            using (await UIThreadHelper.Instance.Invoke(() => _workflow.GetOrCreateVisualComponent(interactiveWindowComponentContainerFactory))) {
                _workflow.ActiveWindow.Should().NotBeNull();
                _workflow.RSession.IsHostRunning.Should().BeTrue();

                using (var eval = await _workflow.RSession.BeginEvaluationAsync()) {
                    await SetLocalRepoAsync(eval, _repo1Path);
                }

                _workflow.Packages.InstallPackage(TestPackages.RtvsLib1Description.Package, _libPath);
                WaitForReplDoneExecuting();
                WaitForPackageInstalled(_libPath, TestPackages.RtvsLib1Description.Package);

                using (var eval = await _workflow.RSession.BeginEvaluationAsync()) {
                    await SetLocalLibsAsync(eval, _libPath);
                }

                var installed = await _workflow.Packages.GetInstalledPackagesAsync();

                ValidateRtvslib1Installed(installed, _libPath);

                _workflow.Packages.UninstallPackage(TestPackages.RtvsLib1Description.Package, _libPath);
                WaitForReplDoneExecuting();

                installed = await _workflow.Packages.GetInstalledPackagesAsync();

                installed.Should().NotContain(pkg => pkg.Package == TestPackages.RtvsLib1Description.Package && pkg.LibPath == _libPath.ToRPath());
            }
        }
コード例 #2
0
ファイル: ReplCommandTest.cs プロジェクト: nomada2/RTVS
        public async Task InterruptRStatusTest()
        {
            var command = new InterruptRCommand(_workflow, _debuggerModeTracker);

            command.Should().BeInvisibleAndDisabled();

            using (await UIThreadHelper.Instance.Invoke(() => _workflow.GetOrCreateVisualComponent(_componentContainerFactory))) {
                command.Should().BeVisibleAndDisabled();

                await _workflow.RSession.BeginEvaluationAsync();

                command.Should().BeVisibleAndEnabled();

                _debuggerModeTracker.OnModeChange(DBGMODE.DBGMODE_Break);
                command.Should().BeVisibleAndDisabled();

                _debuggerModeTracker.OnModeChange(DBGMODE.DBGMODE_Run);
                command.Should().BeVisibleAndEnabled();

                command.Invoke();
                command.Should().BeVisibleAndDisabled();
            }

            command.Should().BeVisibleAndDisabled();
        }
コード例 #3
0
ファイル: RPlotIntegrationUITest.cs プロジェクト: jflam/RTVS
        public async Task InitializeAsync()
        {
            _plotVisualComponent.Control.Width  = 600;
            _plotVisualComponent.Control.Height = 500;
            _replVisualComponent = await _workflow.GetOrCreateVisualComponent(_componentContainerFactory);

            _containerDisposable = await _containerHost.AddToHost(_plotVisualComponent.Control);
        }
コード例 #4
0
        public async Task SourceRScriptTest(bool echo, string encoding)
        {
            var session = _workflow.RSession;
            await session.ExecuteAsync("sourced <- FALSE");

            var tracker = Substitute.For <IActiveWpfTextViewTracker>();

            tracker.GetLastActiveTextView(RContentTypeDefinition.ContentType).Returns((IWpfTextView)null);

            var command = new SourceRScriptCommand(_workflow, tracker, echo);

            command.Should().BeSupported()
            .And.BeInvisibleAndDisabled();

            using (await _workflow.GetOrCreateVisualComponent(_componentContainerFactory)) {
                const string code       = "sourced <- TRUE";
                var          textBuffer = new TextBufferMock(code, RContentTypeDefinition.ContentType);
                var          textView   = new WpfTextViewMock(textBuffer);

                tracker.GetLastActiveTextView(RContentTypeDefinition.ContentType).Returns(textView);
                tracker.LastActiveTextView.Returns(textView);

                command.Should().BeSupported()
                .And.BeVisibleAndDisabled();

                using (var sf = new SourceFile(code)) {
                    var document = new TextDocumentMock(textBuffer, sf.FilePath)
                    {
                        Encoding = Encoding.GetEncoding(encoding)
                    };

                    textBuffer.Properties[typeof(ITextDocument)] = document;

                    command.Should().BeSupported()
                    .And.BeVisibleAndEnabled();

                    var mutatedTask = EventTaskSources.IRSession.Mutated.Create(session);

                    await command.InvokeAsync();

                    await mutatedTask;
                    (await session.EvaluateAsync <bool>("sourced", REvaluationKind.Normal)).Should().BeTrue();
                }
            }
        }
コード例 #5
0
        public async Task InitializeProjectFromDiskAsync()
        {
            await Project.CreateInMemoryImport();

            _fileWatcher.Start();

            await _threadHandling.SwitchToUIThread();

            // Make sure R package is loaded
            VsAppShell.EnsurePackageLoaded(RGuidList.RPackageGuid);

            // Verify project is not on a network share and give warning if it is
            CheckRemoteDrive(_projectDirectory);

            _workflow = _workflowProvider.GetOrCreate();
            _session  = _workflow.RSession;
            _history  = _workflow.History;

            if (_workflow.ActiveWindow == null)
            {
                var window = await _workflow.GetOrCreateVisualComponent(_componentContainerFactory);

                window.Container.Show(true);
            }

            try {
                await _session.HostStarted;
            } catch (Exception) {
                return;
            }

            // TODO: need to compute the proper paths for remote, but they might not even exist if the project hasn't been deployed.
            // https://github.com/Microsoft/RTVS/issues/2223
            if (!_session.IsRemote)
            {
                var  rdataPath            = Path.Combine(_projectDirectory, DefaultRDataName);
                bool loadDefaultWorkspace = _fileSystem.FileExists(rdataPath) && await GetLoadDefaultWorkspace(rdataPath);

                using (var evaluation = await _session.BeginEvaluationAsync()) {
                    if (loadDefaultWorkspace)
                    {
                        await evaluation.LoadWorkspaceAsync(rdataPath);
                    }

                    await evaluation.SetWorkingDirectoryAsync(_projectDirectory);
                }

                _toolsSettings.WorkingDirectory = _projectDirectory;
            }

            _history.TryLoadFromFile(Path.Combine(_projectDirectory, DefaultRHistoryName));

            CheckSurveyNews();
        }
コード例 #6
0
        public async Task InitializeProjectFromDiskAsync()
        {
            await Project.CreateInMemoryImport();

            _fileWatcher.Start();

            // Force REPL window up and continue only when it is shown
            await _threadHandling.SwitchToUIThread();

            // Make sure R package is loaded
            VsAppShell.EnsurePackageLoaded(RGuidList.RPackageGuid);

            // Verify project is not on a network share and give warning if it is
            CheckRemoteDrive(_projectDirectory);

            _workflow = _workflowProvider.GetOrCreate();
            _session  = _workflow.RSession;
            _history  = _workflow.History;

            if (_workflow.ActiveWindow == null)
            {
                var window = await _workflow.GetOrCreateVisualComponent(_componentContainerFactory);

                window.Container.Show(true);
            }

            try {
                await _session.HostStarted;
            } catch (Exception) {
                return;
            }

            var  rdataPath            = Path.Combine(_projectDirectory, DefaultRDataName);
            bool loadDefaultWorkspace = _fileSystem.FileExists(rdataPath) && await GetLoadDefaultWorkspace(rdataPath);

            using (var evaluation = await _session.BeginEvaluationAsync()) {
                if (loadDefaultWorkspace)
                {
                    await evaluation.LoadWorkspace(rdataPath);
                }

                await evaluation.SetWorkingDirectory(_projectDirectory);
            }

            _toolsSettings.WorkingDirectory = _projectDirectory;
            _history.TryLoadFromFile(Path.Combine(_projectDirectory, DefaultRHistoryName));

            CheckSurveyNews();
        }
コード例 #7
0
ファイル: RProjectLoadHooks.cs プロジェクト: int19h/RTVS-OLD
        public async Task InitializeProjectFromDiskAsync() {
            await Project.CreateInMemoryImport();
            _fileWatcher.Start();

            // Force REPL window up and continue only when it is shown
            await _threadHandling.SwitchToUIThread();

            // Make sure R package is loaded
            VsAppShell.EnsurePackageLoaded(RGuidList.RPackageGuid);

            // Verify project is not on a network share and give warning if it is
            CheckRemoteDrive(_projectDirectory);

            _workflow = _workflowProvider.GetOrCreate();
            _session = _workflow.RSession;
            _history = _workflow.History;

            if (_workflow.ActiveWindow == null) {
                var window = await _workflow.GetOrCreateVisualComponent(_componentContainerFactory);
                window.Container.Show(true);
            }

            try {
                await _session.HostStarted;
            } catch (Exception) {
                return;
            }

            var rdataPath = Path.Combine(_projectDirectory, DefaultRDataName);
            bool loadDefaultWorkspace = _fileSystem.FileExists(rdataPath) && await GetLoadDefaultWorkspace(rdataPath);

            using (var evaluation = await _session.BeginEvaluationAsync()) {
                if (loadDefaultWorkspace) {
                    await evaluation.LoadWorkspace(rdataPath);
                }

                await evaluation.SetWorkingDirectory(_projectDirectory);
            }

            _toolsSettings.WorkingDirectory = _projectDirectory;
            _history.TryLoadFromFile(Path.Combine(_projectDirectory, DefaultRHistoryName));
        }
コード例 #8
0
ファイル: RPlotIntegrationTest.cs プロジェクト: jflam/RTVS
 public async Task InitializeAsync()
 {
     _plotDeviceVisualComponentContainerFactory.DeviceProperties = new PlotDeviceProperties(600, 500, 96);
     _replVisualComponent = await _workflow.GetOrCreateVisualComponent(_componentContainerFactory);
 }
コード例 #9
0
 public async Task AllCommandsDisabledWhenNoPlot()
 {
     using (await _workflow.GetOrCreateVisualComponent(_componentContainerFactory)) {
         CheckEnabledCommands(isFirst: false, isLast: false, anyPlot: false);
     }
 }
コード例 #10
0
        public async Task InitializeAsync()
        {
            var componentFactory = _exportProvider.GetExportedValue <IInteractiveWindowComponentContainerFactory>();

            _workflowComponent = await UIThreadHelper.Instance.Invoke(() => _workflow.GetOrCreateVisualComponent(componentFactory));
        }