示例#1
0
        public void ReturnNewProcessReferenceIfProcessNotFound()
        {
            var processRetriever = new ProcessRetriever();

            using (var process = Process.GetCurrentProcess())
            {
                Assert.IsType(typeof(ProcessWrapper), processRetriever.GetProcessById(process.Id));
            }
        }
示例#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);
            }
        }
示例#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));
            }
        }
示例#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));
            }
        }
示例#5
0
        public void ReturnUnknownProcessIfProcessIdNotFound()
        {
            var processRetriever = new ProcessRetriever();

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