예제 #1
0
        /*This test will differ base on if it's run as administrator
         * If so it tests FindFirstStartedProcess execution
         * Else it test if proper exception is thrown (Exception that is should be run as admin)*/
        public void FindFirstStartedProcessFalseTest()
        {
            ProcessInformations info = new ProcessInformations(new List <string>()
            {
            });

            try
            {
                Assert.AreNotEqual(DateTime.Now, info.FindFirstStartedProcess("smss"));
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(System.ComponentModel.Win32Exception));
            }
        }
예제 #2
0
        /*This test will differ base on if it's run as administrator
         * If so it tests FindFirstStartedProcess execution
         * Else it test if proper exception is thrown (Exception that is should be run as admin)*/
        public void FindFirstStartedProcessExceptionTest()
        {
            ProcessInformations info = new ProcessInformations(new List <string>()
            {
            });

            try
            {
                Assert.ThrowsException <ArgumentException>((Action)(() => info.FindFirstStartedProcess("hefalump45366sadvjhhgckxz.exe")));
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(System.ComponentModel.Win32Exception));
            }
        }
예제 #3
0
        /*This test will differ base on if it's run as administrator
         * If so it tests FindFirstStartedProcess execution
         * Else it test if proper exception is thrown (Exception that is should be run as admin)*/
        public void FindFirstStartedProcessExeTest()
        {
            ProcessInformations info = new ProcessInformations(new List <string>()
            {
            });
            var proccess = Process.GetProcessesByName("smss")[0];

            try
            {
                Assert.AreEqual(proccess.StartTime, info.FindFirstStartedProcess("smss.exe"));
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(System.ComponentModel.Win32Exception));
            }
        }