コード例 #1
0
        public void GetProcessesByNameTest()
        {
            using (Notepad notepad = new Notepad())
            using (TempFile tempFile = new TempFile("xpto_test.txt"))
            {
                notepad.OpenFile(tempFile.FilePath);
                Thread.Sleep(1000);
                var result = new ProcessService().GetProcessesByName("xpto_test.txt").Count;

                Assert.AreEqual(1, result);
            }
        }
コード例 #2
0
        public void GetProcessByPidTest()
        {
            using (Notepad notepad = new Notepad())
            using (TempFile tempFile = new TempFile("xpto_test_2.txt"))
            {
                notepad.OpenFile(tempFile.FilePath);
                Thread.Sleep(1000);
                var pid = new ProcessService().GetProcessesByName("xpto_test_2.txt")[0];
                System.Diagnostics.Process result = new ProcessService().GetProcessByPid(pid);

                Assert.IsNotNull(result);
            }
        }