예제 #1
0
        public void TestStartStop2()
        {
            using (var silo = new SharpRemote.Hosting.OutOfProcessSilo())
            {
                silo.Start();
                silo.Stop();

                Thread.Sleep(TimeSpan.FromSeconds(1));
                silo.IsProcessRunning.Should().BeFalse();
                silo.HostProcessId.Should().NotHaveValue();
            }
        }
예제 #2
0
        public void TestStop()
        {
            using (var silo = new SharpRemote.Hosting.OutOfProcessSilo())
            {
                silo.IsProcessRunning.Should().BeFalse("because Start() hasn't been called yet");
                silo.HostProcessId.Should().NotHaveValue("because Start() hasn't been called yet");
                silo.IsConnected.Should().BeFalse("because Start() hasn't been called yet");

                silo.Stop();
                silo.IsProcessRunning.Should().BeFalse("because Start() hasn't been called yet");
                silo.HostProcessId.Should().NotHaveValue("because Start() hasn't been called yet");
                silo.IsConnected.Should().BeFalse("because Start() hasn't been called yet");
            }
        }
예제 #3
0
        public void TestStartStopStart1()
        {
            using (var silo = new SharpRemote.Hosting.OutOfProcessSilo())
            {
                silo.Start();
                silo.Stop();

                silo.Start();
                silo.IsProcessRunning.Should().BeTrue();
                var pid = silo.HostProcessId;
                pid.Should().HaveValue();
                ProcessShouldBeRunning(pid.Value);
            }
        }
예제 #4
0
        public void TestStartStop4()
        {
            using (var collector = new LogCollector("SharpRemote", Level.Warn, Level.Error, Level.Fatal))
                using (var silo = new SharpRemote.Hosting.OutOfProcessSilo())
                {
                    silo.Start();
                    silo.Stop();

                    Thread.Sleep(TimeSpan.FromSeconds(1));

                    collector.Events.Should().NotContain(x => x.RenderedMessage.Contains("exited unexpectedly"));
                    collector.Events.Should().NotContain(x => x.Level >= Level.Warn);
                }
        }
예제 #5
0
        public void TestStartStopDispose()
        {
            using (var logCollector = new LogCollector("SharpRemote", Level.Info,
                                                       Level.Warn, Level.Error, Level.Fatal))
            {
                var silo = new SharpRemote.Hosting.OutOfProcessSilo();
                silo.Start();
                silo.Stop();

                new Action(silo.Dispose)
                .ShouldNotThrow();

                logCollector.Log.Should().NotContain("Caught exception while disposing");
                logCollector.Log.Should().NotContain("SharpRemote.NotConnectedException");
            }
        }
예제 #6
0
        public void TestStartStop1()
        {
            using (var silo = new SharpRemote.Hosting.OutOfProcessSilo())
            {
                silo.Start();
                silo.IsProcessRunning.Should().BeTrue("because Start() has been called and the host should be running now");
                silo.IsConnected.Should().BeTrue("because Start() has been called and the connection to the host should be running");
                var pid = silo.HostProcessId;
                pid.Should().HaveValue();
                ProcessShouldBeRunning(pid.Value);

                silo.Stop();
                silo.IsProcessRunning.Should().BeFalse();
                silo.HostProcessId.Should().NotHaveValue();

                ProcessShouldNotBeRunning(pid.Value);
            }
        }
예제 #7
0
        public void TestStartStop3()
        {
            var failureHandler = new FailureHandlerMock();

            using (var silo = new SharpRemote.Hosting.OutOfProcessSilo(failureHandler: failureHandler))
            {
                silo.Start();
                silo.Stop();

                Thread.Sleep(TimeSpan.FromSeconds(1));

                const string reason =
                    "because no failure should've occured (due to the intentional shutdown) and therefore the callback may not have been invoked";
                failureHandler.NumStartFailure.Should().Be(0, reason);
                failureHandler.NumFailure.Should().Be(0, reason);
                failureHandler.NumResolutionFailed.Should().Be(0, reason);
                failureHandler.NumResolutionFinished.Should().Be(0, reason);
            }
        }
예제 #8
0
        public void TestStartStopStart2()
        {
            using (var silo = new SharpRemote.Hosting.OutOfProcessSilo())
            {
                silo.Start();

                var proxy = silo.CreateGrain <IReturnsType>(typeof(ReturnsTypeofString));
                proxy.Do().Should().Be <string>();

                silo.Stop();

                new Action(() => proxy.Do())
                .ShouldThrow <RemoteProcedureCallCanceledException>();
                new Action(() => silo.CreateGrain <IReturnsType>(typeof(ReturnsTypeofString)))
                .ShouldThrow <RemoteProcedureCallCanceledException>();

                silo.Start();

                var newProxy = silo.CreateGrain <IReturnsType>(typeof(ReturnsTypeofString));
                newProxy.Do().Should().Be <string>();
            }
        }