public async void TransitionsFromStartingToRunning() { var wdh = new ProcessWatchdogHelper(); wdh.options.Setup(x => x.Value).Returns(new ProcessWatchdogOptions() { ProcessInfo = new ProcessInfo() { FileName = "test.exe", Path = @"C:\", WorkingPath = @"C:\" } }); var path = @"C:\test.exe"; var proc = new Mock <IProcess>(); proc.Setup(x => x.Path).Returns(path); wdh.filesystem.Setup(x => x.FileExists(path)).Returns(true); wdh.process.Setup(x => x.GetByName("test.exe")).Returns(new IProcess[] { proc.Object }); var watchdog = wdh.CreateInstance(); await watchdog.Step(); await watchdog.Step(); Assert.Equal(ProcessWatchdogStates.Running, watchdog.State); Assert.False(watchdog.Failed); }
public async void TransitionsFromInitingToFileNotFound() { var wdh = new ProcessWatchdogHelper(); wdh.options.Setup(x => x.Value).Returns(new ProcessWatchdogOptions() { ProcessInfo = new ProcessInfo() { FileName = "text.exe", Path = @"C:\", WorkingPath = @"C:\" } }); var watchdog = wdh.CreateInstance(); await watchdog.Step(); Assert.Equal(ProcessWatchdogStates.FileNotFound, watchdog.State); }
public async void TransitionsFromInitingToStarting() { var wdh = new ProcessWatchdogHelper(); wdh.options.Setup(x => x.Value).Returns(new ProcessWatchdogOptions() { ProcessInfo = new ProcessInfo() { FileName = "test.exe", Path = @"C:\", WorkingPath = @"C:\" } }); var path = @"C:\test.exe"; wdh.filesystem.Setup(x => x.FileExists(path)).Returns(true); var watchdog = wdh.CreateInstance(); await watchdog.Step(); Assert.Equal(ProcessWatchdogStates.Starting, watchdog.State); }