コード例 #1
0
        public void CheckProcessStatusNotStartedTest()
        {
            ProcessInformations info = new ProcessInformations(new List <string>()
            {
            });

            Assert.AreEqual("NotStarted", info.CheckProcessStatus("hefalump45366sadvjhhgckxz.exe"));
        }
コード例 #2
0
        public void CheckProcessStatusRunningTest()
        {
            ProcessInformations info = new ProcessInformations(new List <string>()
            {
                "smss.exe"
            });

            Assert.AreEqual("Running", info.CheckProcessStatus("smss.exe"));
        }
コード例 #3
0
        public void CheckProcessStatusExitedTest()
        {
            ProcessInformations info = new ProcessInformations(new List <string>()
            {
                "hefalump45366sadvjhhgckxz.exe"
            });

            info.CurrentlyTracked.Add(new RecordModel("hefalump45366sadvjhhgckxz.exe", DateTime.Now));
            Assert.AreEqual("Exited", info.CheckProcessStatus("hefalump45366sadvjhhgckxz.exe"));
        }
コード例 #4
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));
            }
        }
コード例 #5
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));
            }
        }
コード例 #6
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));
            }
        }
コード例 #7
0
        public void CheckIfAppProccessIsRunningFailedTest()
        {
            ProcessInformations info = new ProcessInformations(new List <string>());

            Assert.AreEqual(false, info.CheckIfAppProccessIsRunning("hefalump45366sadvjhhgckxz.exe"));
        }
コード例 #8
0
        public void CheckIfAppProccessIsRunningTest()
        {
            ProcessInformations info = new ProcessInformations(new List <string>());

            Assert.AreEqual(true, info.CheckIfAppProccessIsRunning("smss.exe"));
        }