Dispose() public method

public Dispose ( ) : void
return void
Ejemplo n.º 1
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>();
        }
Ejemplo n.º 2
0
        public async Task SwitchBroker_DisposeSessionProvider(int timeout) {
            var sessionProvider = new RSessionProvider(TestCoreServices.CreateReal());
            var guid = new Guid();
            var session1 = sessionProvider.GetOrCreate(guid);
            var session2 = sessionProvider.GetOrCreate(guid);
            session2.RestartOnBrokerSwitch = true;

            await sessionProvider.TrySwitchBrokerAsync(nameof(RSessionProviderTest) + nameof(SwitchBrokerWithCancellation));
            await session1.EnsureHostStartedAsync(new RHostStartupInfo {
                Name = nameof(session1)
            }, null, 5000).Should().BeCompletedAsync();
            await session2.HostStarted.Should().BeCompletedAsync();

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

            result.Should().BeFalse();
        }