예제 #1
0
        public async Task SwitchBroker_DisposeSessionProvider(int timeout)
        {
            var sessionProvider = new RSessionProvider(_services);
            var session1        = sessionProvider.GetOrCreate(nameof(SwitchBroker_DisposeSessionProvider) + 1);
            var session2        = sessionProvider.GetOrCreate(nameof(SwitchBroker_DisposeSessionProvider) + 2);

            session2.RestartOnBrokerSwitch = true;

            await sessionProvider.TrySwitchBrokerAsync(nameof(RSessionProviderTest) + nameof(SwitchBroker_DisposeSessionProvider));

            await session1.EnsureHostStartedAsync(new RHostStartupInfo(), null, 5000).Should().BeCompletedAsync();

            await session2.HostStarted.Should().BeCompletedAsync();

            var sessionProviderDisposeTask = Task.Delay(timeout).ContinueWith(t => sessionProvider.Dispose());

            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var result = await sessionProvider.TrySwitchBrokerAsync(nameof(RSessionProviderTest) + nameof(SwitchBroker_DisposeSessionProvider) + "1");

            stopwatch.Stop();

            await sessionProviderDisposeTask;

            result.Should().Be(stopwatch.ElapsedMilliseconds < timeout);
        }
예제 #2
0
        public async Task DisposeAsync()
        {
            await _session.StopHostAsync();

            _sessionProvider.Dispose();
            _brokerConnector.Dispose();
        }
예제 #3
0
        public void Lifecycle()
        {
            var sessionProvider = new RSessionProvider(_services);
            // ReSharper disable once AccessToDisposedClosure
            Action a = () => sessionProvider.GetOrCreate(nameof(Lifecycle));

            a.ShouldNotThrow();

            sessionProvider.Dispose();
            a.ShouldThrow <InvalidOperationException>();
        }
예제 #4
0
        public void Lifecycle()
        {
            var sessionProvider = new RSessionProvider(TestCoreServices.CreateReal());
            // ReSharper disable once AccessToDisposedClosure
            Action a = () => sessionProvider.GetOrCreate(new Guid());

            a.ShouldNotThrow();

            sessionProvider.Dispose();
            a.ShouldThrow <InvalidOperationException>();
        }
예제 #5
0
        public void Lifecycle()
        {
            var sessionProvider = new RSessionProvider();
            // ReSharper disable once AccessToDisposedClosure
            Action a = () => sessionProvider.GetOrCreate(new Guid(), _brokerConnector);

            a.ShouldNotThrow();

            sessionProvider.Dispose();
            a.ShouldThrow <InvalidOperationException>();
        }
예제 #6
0
        public async Task SwitchBroker_DisposeSessionProvider(int timeout)
        {
            var sessionProvider = new RSessionProvider(TestCoreServices.CreateReal());
            var guid            = new Guid();
            var session         = sessionProvider.GetOrCreate(guid);
            await sessionProvider.TrySwitchBrokerAsync(nameof(RSessionProviderTest) + nameof(SwitchBrokerWithCancellation));

            await session.EnsureHostStartedAsync(new RHostStartupInfo
            {
                Name = nameof(session)
            }, null, 5000);

            var sessionDisposeTask = Task.Delay(timeout).ContinueWith(t => sessionProvider.Dispose());
            var result             = await sessionProvider.TrySwitchBrokerAsync(nameof(RSessionProviderTest) + nameof(SwitchBrokerWithCancellation) + "1");

            await sessionDisposeTask;

            result.Should().BeFalse();
        }