public void Fires_event_when_any_process_is_started()
        {
            using (var listener = new ProcessListener("notepad.exe"))
            {
                var processWasStarted = false;
                var wait = new ManualResetEvent(false);

                listener.ProcessStarted += delegate
                {
                    processWasStarted = true;
                    wait.Set();
                };

                var processArgs = new ProcessStartInfo("notepad.exe")
                {
                    WindowStyle = ProcessWindowStyle.Hidden
                };

                var process = Process.Start(processArgs);

                try
                {
                    wait.WaitOne(TimeSpan.FromSeconds(5));
                    Assert.AreEqual(true, processWasStarted);
                }
                finally
                {
                    if (!process.HasExited) process.Kill();
                    process.Dispose();
                }
            }
        }
        public void Does_not_fire_event_when_specific_process_is_monitored_but_different_process_starts()
        {
            using (var listener = new ProcessListener("nonexistantprocess.exe"))
            {
                var processWasStarted = false;
                var wait = new ManualResetEvent(false);

                listener.ProcessStarted += delegate
                {
                    processWasStarted = true;
                    wait.Set();
                };

                var processArgs = new ProcessStartInfo("notepad.exe")
                {
                    WindowStyle = ProcessWindowStyle.Hidden
                };

                var process = Process.Start(processArgs);

                try
                {
                    wait.WaitOne(TimeSpan.FromSeconds(2));
                    Assert.AreEqual(false, processWasStarted);
                }
                finally
                {
                    if (!process.HasExited) process.Kill();
                    process.Dispose();
                }
            }
        }