Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }