示例#1
0
            public void FiltersOutMissingProcesses()
            {
                var processes = new[]
                {
                    Process.Start("cmd.exe"),
                    Process.Start("cmd.exe"),
                };

                try
                {
                    var processHelper = new ProcessHelper();

                    var processIds = processes.Select(p => p.Id).ToList();
                    processIds.Add(1);

                    var result = processHelper.GetProcesses(processes.Select(p => p.Id));

                    Assert.Collection(result,
                                      x => Assert.Equal(processes[0].Id, x.Id),
                                      x => Assert.Equal(processes[1].Id, x.Id)
                                      );
                }
                finally
                {
                    foreach (var p in processes)
                    {
                        p.Kill();
                    }
                }
            }
示例#2
0
            public void ReturnsProcesses()
            {
                var processes = new []
                {
                    Process.Start("cmd.exe"),
                    Process.Start("cmd.exe"),
                };

                try
                {
                    var processHelper = new ProcessHelper();

                    var result = processHelper.GetProcesses(processes.Select(p => p.Id));

                    Assert.Collection(result,
                                      x => Assert.Equal(processes[0].Id, x.Id),
                                      x => Assert.Equal(processes[1].Id, x.Id)
                                      );
                }
                finally
                {
                    foreach (var p in processes)
                    {
                        p.Kill();
                    }
                }
            }
            public void FiltersOutMissingProcesses()
            {
                var processes = new[]
                {
                    Process.Start("cmd.exe"),
                    Process.Start("cmd.exe"),
                };

                try
                {
                    var processHelper = new ProcessHelper();

                    var processIds = processes.Select(p => p.Id).ToList();
                    processIds.Add(1);

                    var result = processHelper.GetProcesses(processes.Select(p => p.Id));

                    Assert.Collection(result,
                        x => Assert.Equal(processes[0].Id, x.Id),
                        x => Assert.Equal(processes[1].Id, x.Id)
                    );
                }
                finally
                {
                    foreach (var p in processes)
                        p.Kill();
                }
            }
            public void ReturnsProcesses()
            {
                var processes = new []
                {
                    Process.Start("cmd.exe"),
                    Process.Start("cmd.exe"),
                };

                try
                {
                    var processHelper = new ProcessHelper();

                    var result = processHelper.GetProcesses(processes.Select(p => p.Id));

                    Assert.Collection(result,
                        x => Assert.Equal(processes[0].Id, x.Id),
                        x => Assert.Equal(processes[1].Id, x.Id)
                    );
                }
                finally
                {
                    foreach (var p in processes)
                        p.Kill();
                }
            }