Beispiel #1
0
        public async Task RestartProcessThatTerminatesAfterFileChange()
        {
            await _app.StartWatcherAsync();

            var processIdentifier = await _app.GetProcessIdentifier();

            await _app.HasExited(); // process should exit after run

            await _app.IsWaitingForFileChange();

            var fileToChange = Path.Combine(_app.SourceDirectory, "Program.cs");

            try
            {
                File.SetLastWriteTime(fileToChange, DateTime.Now);
                await _app.HasRestarted();
            }
            catch
            {
                // retry
                File.SetLastWriteTime(fileToChange, DateTime.Now);
                await _app.HasRestarted();
            }

            var processIdentifier2 = await _app.GetProcessIdentifier();

            Assert.NotEqual(processIdentifier, processIdentifier2);
            await _app.HasExited(); // process should exit after run
        }
        public async Task RestartProcessThatTerminatesAfterFileChange()
        {
            await _app.StartWatcherAsync();

            var pid = await _app.GetProcessId();

            await _app.HasExited(); // process should exit after run

            var fileToChange = Path.Combine(_app.SourceDirectory, "Program.cs");
            var programCs    = File.ReadAllText(fileToChange);

            File.WriteAllText(fileToChange, programCs);

            await _app.HasRestarted();

            var pid2 = await _app.GetProcessId();

            Assert.NotEqual(pid, pid2);
            await _app.HasExited(); // process should exit after run
        }