Ejemplo n.º 1
0
        public async Task SwitchMultipleSessions()
        {
            using (var sessionProvider = new RSessionProvider(_services)) {
                await sessionProvider.TrySwitchBrokerAsync(nameof(RSessionProviderTest) + nameof(SwitchMultipleSessions)).Should().BeCompletedAsync();

                var sessions = new IRSession[4];
                for (var i = 0; i < sessions.Length; i++)
                {
                    sessions[i] = sessionProvider.GetOrCreate(nameof(SwitchMultipleSessions) + i);
                    sessions[i].RestartOnBrokerSwitch = true;
                }

                await ParallelTools.WhenAll(30000, sessions.Select((s, i) => s.EnsureHostStartedAsync(new RHostStartupInfo(), null, 30000)).ToArray());

                await sessionProvider.TrySwitchBrokerAsync(nameof(RSessionProviderTest) + nameof(SwitchMultipleSessions) + "1").Should().BeCompletedAsync();

                sessions.Should().OnlyContain(s => s.IsHostRunning);
            }
        }
Ejemplo n.º 2
0
        public async Task SwitchMultipleSessions()
        {
            using (var sessionProvider = new RSessionProvider(TestCoreServices.CreateReal())) {
                await sessionProvider.TrySwitchBrokerAsync(nameof(RSessionProviderTest) + nameof(SwitchMultipleSessions));

                var sessions = new IRSession[4];
                for (var i = 0; i < sessions.Length; i++)
                {
                    sessions[i] = sessionProvider.GetOrCreate(new Guid());
                }

                await Task.WhenAll(sessions.Select((s, i) => s.EnsureHostStartedAsync(new RHostStartupInfo {
                    Name = nameof(sessions) + i
                }, null, 30000)));

                await sessionProvider.TrySwitchBrokerAsync(nameof(RSessionProviderTest) + nameof(SwitchMultipleSessions) + "1");

                sessions.Should().OnlyContain(s => s.IsHostRunning);
            }
        }
Ejemplo n.º 3
0
        public async Task SwitchMultipleSessions() {
            using (var sessionProvider = new RSessionProvider(TestCoreServices.CreateReal())) {
                await sessionProvider.TrySwitchBrokerAsync(nameof(RSessionProviderTest) + nameof(SwitchMultipleSessions)).Should().BeCompletedAsync();

                var sessions = new IRSession[4];
                for (var i = 0; i < sessions.Length; i++) {
                    sessions[i] = sessionProvider.GetOrCreate(new Guid());
                    sessions[i].RestartOnBrokerSwitch = true;
                }

                await ParallelTools.WhenAll(30000, sessions.Select((s, i) => s.EnsureHostStartedAsync(new RHostStartupInfo {
                    Name = nameof(sessions) + i
                }, null, 30000)).ToArray());

                await sessionProvider.TrySwitchBrokerAsync(nameof(RSessionProviderTest) + nameof(SwitchMultipleSessions) + "1").Should().BeCompletedAsync();

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