Exemplo n.º 1
0
        private async Task <IEnumerable <string> > GraphicsTestAsync(string[] inputs)
        {
            using (var sessionProvider = new RSessionProvider()) {
                var session = sessionProvider.GetOrCreate(Guid.NewGuid(), new RHostClientTestApp {
                    PlotHandler = OnPlot
                });
                await session.StartHostAsync(new RHostStartupInfo {
                    Name      = _testMethod.Name,
                    RBasePath = RUtilities.FindExistingRBasePath()
                }, 50000);

                foreach (var input in inputs)
                {
                    using (var interaction = await session.BeginInteractionAsync()) {
                        await interaction.RespondAsync(input + "\n");
                    }
                }

                await session.StopHostAsync();
            }

            // Ensure that all plot files created by the graphics device have been deleted
            foreach (var deletedFilePath in OriginalPlotFilePaths)
            {
                File.Exists(deletedFilePath).Should().BeFalse();
            }

            return(PlotFilePaths.AsReadOnly());
        }
Exemplo n.º 2
0
 public async Task InitializeAsync()
 {
     await _session.StartHostAsync(new RHostStartupInfo {
         Name      = _testMethod.Name,
         RBasePath = RUtilities.FindExistingRBasePath()
     }, new RHostClientTestApp(), 50000);
 }
Exemplo n.º 3
0
            public async Task InitializeAsync()
            {
                await _session.StartHostAsync(new RHostStartupInfo {
                    Name      = _testMethod.Name,
                    RBasePath = RUtilities.FindExistingRBasePath()
                }, null, 50000);

                _testMethodFixture.ObserveTaskFailure(_session.RHost.GetRHostRunTask());
            }
Exemplo n.º 4
0
        private async Task ExecuteInSession(string[] inputs, IRSessionCallback app)
        {
            using (var sessionProvider = new RSessionProvider()) {
                var session = sessionProvider.GetOrCreate(Guid.NewGuid());
                await session.StartHostAsync(new RHostStartupInfo {
                    Name      = _testMethod.Name,
                    RBasePath = RUtilities.FindExistingRBasePath()
                }, app, 50000);

                foreach (var input in inputs)
                {
                    using (var interaction = await session.BeginInteractionAsync()) {
                        await interaction.RespondAsync(input + "\n");
                    }
                }

                await session.StopHostAsync();
            }
        }
Exemplo n.º 5
0
        public async Task DoubleStart()
        {
            var         session = new RSession(0, () => { });
            Func <Task> start   = () => session.StartHostAsync(new RHostStartupInfo {
                Name      = _testMethod.Name,
                RBasePath = RUtilities.FindExistingRBasePath()
            }, null, 50000);

            Func <Task> f = () => ParallelTools.InvokeAsync(4, i => start());

            f.ShouldThrow <InvalidOperationException>();

            await session.HostStarted;

            session.IsHostRunning.Should().BeTrue();

            await session.StopHostAsync();

            session.IsHostRunning.Should().BeFalse();
        }
Exemplo n.º 6
0
        public async Task StartStop()
        {
            var session = new RSession(0, () => { });

            session.HostStarted.Status.Should().Be(TaskStatus.Canceled);
            session.IsHostRunning.Should().BeFalse();

            await session.StartHostAsync(new RHostStartupInfo {
                Name      = _testMethod.Name,
                RBasePath = RUtilities.FindExistingRBasePath()
            }, null, 50000);

            session.HostStarted.Status.Should().Be(TaskStatus.RanToCompletion);
            session.IsHostRunning.Should().BeTrue();

            await session.StopHostAsync();

            session.HostStarted.Status.Should().Be(TaskStatus.Canceled);
            session.IsHostRunning.Should().BeFalse();
        }
Exemplo n.º 7
0
        private async Task<XDocument> RunGraphicsTest(string code, string outputFilePath) {
            using (var sessionProvider = new RSessionProvider()) {
                var session = sessionProvider.GetOrCreate(Guid.NewGuid());
                await session.StartHostAsync(new RHostStartupInfo {
                    Name = _testMethod.Name,
                    RBasePath = RUtilities.FindExistingRBasePath()
                }, new RHostClientTestApp(), 50000);

                using (var interaction = await session.BeginInteractionAsync()) {
                    await interaction.RespondAsync(code);
                }

                await session.StopHostAsync();
            }

            File.Exists(outputFilePath).Should().BeTrue();
            var doc = XDocument.Load(outputFilePath);
            var docXml = doc.ToString();
            Console.WriteLine(docXml);
            return doc;
        }
Exemplo n.º 8
0
        public async Task StartStopMultipleSessions()
        {
            Func <int, Task <RSession> > start = async i => {
                var session = new RSession(i, () => { });
                await session.StartHostAsync(new RHostStartupInfo { Name = _testMethod.Name, RBasePath = RUtilities.FindExistingRBasePath() }, null, 50000);

                return(session);
            };

            var sessions = await ParallelTools.InvokeAsync(4, start);

            sessions.Should().OnlyContain(s => s.IsHostRunning);

            await ParallelTools.InvokeAsync(4, i => sessions[i].StopHostAsync());

            sessions.Should().OnlyContain(s => !s.IsHostRunning);
        }
Exemplo n.º 9
0
 public static RSettingsStub CreateForExistingRPath()
 {
     return(new RSettingsStub {
         RBasePath = RUtilities.FindExistingRBasePath()
     });
 }