Inheritance: IRSessionCallback
 public CancelAll(TestMethodFixture testMethod, TaskObserverMethodFixture taskObserver) {
     _taskObserver = taskObserver;
     _testMethod = testMethod.MethodInfo;
     _brokerClient = CreateLocalBrokerClient(nameof(RSessionTest) + nameof(CancelAll));
     _callback = new RSessionCallbackStub();
     _session = new RSession(0, _brokerClient, new AsyncReaderWriterLock().CreateExclusiveReaderLock(), () => {});
 }
Exemple #2
0
        public async Task StopReentrantLoop() {
            var callback = new RSessionCallbackStub();
            var session = new RSession(0, _brokerClient, new AsyncReaderWriterLock().CreateExclusiveReaderLock(), () => { });

            await session.StartHostAsync(new RHostStartupInfo {
                Name = _testMethod.Name
            }, callback, 50000);

            var testMrs = new AsyncManualResetEvent();
            callback.PlotHandler = (message, ct) => {
                testMrs.Set();
                return session.EvaluateAsync("x <- 1\n");
            };

            Task responceTask;
            using (var interaction = await session.BeginInteractionAsync()) {
                responceTask = interaction.RespondAsync("plot(1)\n");
            }

            await testMrs.WaitAsync().Should().BeCompletedAsync();

            await session.StopHostAsync().Should().BeCompletedAsync(20000);
            session.IsHostRunning.Should().BeFalse();

            await responceTask.Should().BeCanceledAsync();
        }