Esempio n. 1
0
        public void ReturnNewProcessReferenceIfProcessNotFound()
        {
            var processRetriever = new ProcessRetriever();

            using (var process = Process.GetCurrentProcess())
            {
                Assert.IsType(typeof(ProcessWrapper), processRetriever.GetProcessById(process.Id));
            }
        }
Esempio n. 2
0
        public void ReturnSameProcessReferenceIfProcessFoundAndNotExited()
        {
            var processRetriever = new ProcessRetriever();

            using (var process = Process.GetCurrentProcess())
            {
                var referencedProcess1 = processRetriever.GetProcessById(process.Id);
                var referencedProcess2 = processRetriever.GetProcessById(process.Id);

                Assert.Same(referencedProcess1, referencedProcess2);
            }
        }
Esempio n. 3
0
        public void ReturnUnknownProcessIfProcessExitedBeforeWrapped()
        {
            var processRetriever = new ProcessRetriever();

            using (var process = Process.Start(new ProcessStartInfo("cmd") { CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden }))
            {
                var processId = process.Id;

                process.KillAndWaitForExit();

                Assert.IsType(typeof(UnknownProcess), processRetriever.GetProcessById(processId));
            }
        }
Esempio n. 4
0
        public void ReturnCachedProcessReferenceIfProcessExits()
        {
            var processRetriever = new ProcessRetriever();

            using (var process = Process.Start(new ProcessStartInfo("cmd") { CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden }))
            {
                Assert.IsType(typeof(ProcessWrapper), processRetriever.GetProcessById(process.Id));

                process.KillAndWaitForExit();

                Assert.IsType(typeof(ProcessWrapper), processRetriever.GetProcessById(process.Id));
            }
        }
Esempio n. 5
0
        public void ReturnUnknownProcessIfProcessIdNotFound()
        {
            var processRetriever = new ProcessRetriever();

            Assert.IsType(typeof(UnknownProcess), processRetriever.GetProcessById(9999999));
        }