Beispiel #1
0
 public void TestExecute()
 {
     using CWrapper wrapper = new CWrapper(Constants.ECHO_CONSOLE_LOCATION);
     wrapper.Execute();
     Assert.True(wrapper.Executing);
     Assert.Throws <InvalidOperationException>(() => wrapper.Execute());
     wrapper.Kill();
 }
Beispiel #2
0
 public void TestKill()
 {
     using CWrapper wrapper = new CWrapper(Constants.ECHO_CONSOLE_LOCATION);
     wrapper.Execute();
     wrapper.Kill();
     Assert.False(wrapper.Executing);
 }
Beispiel #3
0
        public static void Main()
        {
            CWrapper wrapper = new CWrapper("cmd");

            wrapper.OutputDataReceived += (s, e) => Console.WriteLine(e.Data);
            wrapper.Execute("/C ping www.google.co.nz");
            wrapper.ExitedMRE.Wait();
        }
Beispiel #4
0
        public void TestExitEvent()
        {
            using CWrapper wrapper = new CWrapper(Constants.ECHO_CONSOLE_LOCATION);
            DateTime exitTime = DateTime.MinValue;

            wrapper.Exited += (_, e) => exitTime = e;
            wrapper.Execute(EchoConsole.Program.EXIT_KEY);
            wrapper.ExitedMRE.Wait();
            Assert.True(exitTime.AddMilliseconds(10) > DateTime.Now);
        }
Beispiel #5
0
        public void TestKillEventFired()
        {
            using CWrapper wrapper = new CWrapper(Constants.ECHO_CONSOLE_LOCATION);
            bool eventFired = false;

            wrapper.Killed += (_, __) => eventFired = true;
            wrapper.Execute();
            wrapper.Kill();
            wrapper.KilledMRE.Wait();
            Assert.True(eventFired);
        }
Beispiel #6
0
        public void TestOutput()
        {
            using CWrapper wrapper = GetWrapper();

            string returnData = null;

            wrapper.OutputDataReceived += (_, e) => returnData = e.Data;

            wrapper.Execute(EchoConsole.Program.FLOOD_KEY);
            wrapper.OutputDataMRE.Wait();
            wrapper.Kill();

            Assert.Equal(EchoConsole.Program.FLOOD_OUTPUT, returnData);
        }
Beispiel #7
0
        public void TestInput()
        {
            const string ECHO_DATA  = "This data shall be echoed";
            string       returnData = null;

            using CWrapper wrapper      = GetWrapper();
            wrapper.OutputDataReceived += (_, e) => returnData = e.Data;

            wrapper.Execute();
            wrapper.WriteToConsole(ECHO_DATA);
            wrapper.OutputDataMRE.Wait();
            wrapper.Kill();

            Assert.Equal(ECHO_DATA, returnData);
        }