Ejemplo n.º 1
0
        public void KillAllSpawning()
        {
            // we check that processes can spawn new processes when being killed, and that we ignore those processes
            var mock = new Program.MockAction(p => this.manager.Spawn(null, "killme"));

            Program.Process process1 = this.manager.Spawn(null, "killme", mock.Action);
            Program.Process process2 = this.manager.Spawn(null, "killme", mock.Action);

            this.manager.KillAll("killme");

            Assert.IsFalse(process2.Alive);
            Assert.IsFalse(process1.Alive);
            Assert.AreEqual(2, mock.CallCount);

            var processes = new List <string>();

            this.manager.Log(s => processes.Add(s));

            Assert.AreEqual(2, processes.Count(s => s.Contains("killme")));

            // Although ignored at first because spawned during the KillAll call, a subsequent call to KillAll will kill them
            this.manager.KillAll("killme");
            processes.Clear();
            this.manager.Log(s => processes.Add(s));

            Assert.AreEqual(0, processes.Count(s => s.Contains("killme")));
        }
Ejemplo n.º 2
0
        public void SelfTerminatingProcess()
        {
            Program.Process process = this.manager.Spawn(p => p.Done());

            this.tick();

            Assert.IsFalse(process.Alive);
        }
Ejemplo n.º 3
0
        public void SelfKillingProcess()
        {
            Program.Process process = this.manager.Spawn(p => p.Kill());

            this.tick();

            Assert.IsFalse(process.Alive);
        }
Ejemplo n.º 4
0
 public void BeforeEach()
 {
     this.commandCalls = new List <string>();
     this.manager      = Program.Process.CreateManager(s => System.Diagnostics.Debug.WriteLine(s));
     this.commandLine  = new Program.CommandLine("test", null, this.manager);
     this.commandLine.RegisterCommand(new Program.Command("cmd", this.command, "", requiredTrigger: Program.CommandTrigger.Cmd));
     this.mock    = new Program.MockAction();
     this.process = this.manager.Spawn(null, "test");
 }
Ejemplo n.º 5
0
        public void SelfKillingInCallbackProcess()
        {
            var mock = new Program.MockAction(p => p.Kill());

            Program.Process process = this.manager.Spawn(null, onDone: mock.Action);

            process.Kill();

            Assert.IsFalse(process.Alive);
        }
Ejemplo n.º 6
0
 public void Action(Program.Process p)
 {
     this.calls.Add(p);
     this.action?.Invoke();
 }