Esempio n. 1
0
        public void GivenProcessUnderWatch_WhenRemoveProcess_ThenItRemovesProperly()
        {
            Process         runningProcess = ProcessWatchTestHelper.GivenFirstRunningProcess();
            IProcessWatcher watchdog       = GivenProcessWatcher();

            watchdog.AddProcessToWatchList(runningProcess.ProcessName, false);
            IEnumerable <IProcessWatch> processWatches = watchdog.GetProcessUnderWatch();

            Assert.Equal(2, processWatches.Count());

            watchdog.RemoveProcessFromWatchList(runningProcess.ProcessName);
            processWatches = watchdog.GetProcessUnderWatch();

            Assert.Single(processWatches);
        }
Esempio n. 2
0
        public void GivenConfigFile_WhenGettingInitialProcessToWatch_ThenItReturnsProperProcessWatch()
        {
            IProcessWatcher watchdog = GivenProcessWatcher();

            IEnumerable <IProcessWatch> initialTargets = watchdog.GetProcessUnderWatch();

            var processWatches = initialTargets as IProcessWatch[] ?? initialTargets.ToArray();

            Assert.Single(processWatches);
            Assert.Contains(INITIAL_TARGET, processWatches.Single().ProcessName);
        }
Esempio n. 3
0
        public void GivenNotRunningProcess_WhenAddProcessWatch_ProcessIsNotRunning()
        {
            const string    processName = "NOT_A_PROCESS";
            IProcessWatcher watchdog    = GivenProcessWatcher();

            watchdog.AddProcessToWatchList(processName, false);
            IEnumerable <IProcessWatch> processWatches = watchdog.GetProcessUnderWatch();
            IProcessWatch processWatch =
                processWatches.SingleOrDefault(pw => pw.ProcessName.Equals(processName));

            Assert.False(processWatch?.IsRunning);
        }
Esempio n. 4
0
        public void GivenRunningProcess_WhenAddProcessWatch_ProcessIsRunning()
        {
            IProcessWatcher watchdog       = GivenProcessWatcher();
            Process         runningProcess = ProcessWatchTestHelper.GivenFirstRunningProcess();

            watchdog.AddProcessToWatchList(runningProcess.ProcessName, false);
            IEnumerable <IProcessWatch> processWatches = watchdog.GetProcessUnderWatch();
            IProcessWatch processWatch =
                processWatches.SingleOrDefault(pw => pw.ProcessName.Equals(runningProcess.ProcessName));

            Assert.True(processWatch?.IsRunning);
            Assert.Equal(2, processWatches.Count());
        }
 private void StartProcessWatch()
 {
     _processWatcher.RegisterPacketCaptureObserver(this);
     ProcessesUnderWatch = _processWatcher.GetProcessUnderWatch();
     _processWatcher.StartCapture();
 }