Пример #1
0
        public async Task TestThatProcessIsRestarted()
        {
            ProcessStub process = new ProcessStub("exePath", "exeArgs");

            SelfRestartingProcess selfRestartingProcess = new SelfRestartingProcess(process, 1);
            await selfRestartingProcess.Start();
            Assert.IsTrue(process.IsRunning);

            process.RaiseExitedEvent();
            Assert.IsTrue(await SpinWaitForRestart(selfRestartingProcess, 1));
            Assert.IsTrue(process.IsRunning);
        }
Пример #2
0
        public async Task TestThatExitedIsRaisedIfProcessFailsToRestart()
        {
            ProcessStub process = new ProcessStub("exePath", "exeArgs");
            SelfRestartingProcess selfRestartingProcess = new SelfRestartingProcess(process, 1);
            bool exitedFired = false;
            selfRestartingProcess.Exited += (sender, args) => {
                exitedFired = true;
            };

            await selfRestartingProcess.Start();
            Assert.IsTrue(process.IsRunning);

            process.ShouldStart = false;
            process.RaiseExitedEvent();

            Assert.IsTrue(await SpinWaitFor(() => exitedFired));
            Assert.IsFalse(process.IsRunning);
            Assert.IsTrue(exitedFired);
        }
Пример #3
0
 private Task<bool> SpinWaitForRestart(SelfRestartingProcess selfRestartingProcess, int restartCount)
 {
     return SpinWaitFor(() => selfRestartingProcess.RestartCount == restartCount);
 }