Пример #1
0
        /// <summary>
        /// Determines if a process should not be kept around after test execution
        /// </summary>
        /// <returns>whether this process is unwanted</returns>
        private static bool IsUnwantedProcess(DateTime startTime, string userSid, Process process)
        {
            // Don't shutdown a critical process or the developers IDE
            if (ProcessUtilities.IsCriticalProcess(process) || ProcessUtilities.IsIDE(process))
            {
                return(false);
            }

            // Shutdown any process started within the span of the test. This seems overly aggressive but probably has good reason.
            if (userSid.Equals(ProcessUtilities.GetProcessUserSid(process), StringComparison.InvariantCultureIgnoreCase) && !process.HasExited && process.StartTime > startTime)
            {
                return(true);
            }

            // Shutdown any known processes associated with tests
            if (ProcessUtilities.IsKnownTestProcess(process))
            {
                return(true);
            }

            return(false);
        }