예제 #1
0
            protected override Process StartProcess(ProcessStartInfo startInfo)
            {
                if (debuggerSetup != null)
                {
                    IDebugger debugger = new DefaultDebuggerManager().GetDebugger(debuggerSetup, logger);
                    Process   process  = debugger.LaunchProcess(startInfo);
                    if (process != null)
                    {
                        return(process);
                    }
                }

                return(base.StartProcess(startInfo));
            }
예제 #2
0
        private void RunEndpointWithDebugger(ILogger logger)
        {
            Process currentProcess = Process.GetCurrentProcess();

            IDebuggerManager debuggerManager   = new DefaultDebuggerManager(); // FIXME: Get from IoC
            var                  debuggerSetup = new DebuggerSetup();
            IDebugger            debugger      = debuggerManager.GetDebugger(debuggerSetup, logger);
            AttachDebuggerResult attachResult  = AttachDebuggerResult.CouldNotAttach;

            try
            {
                if (!Debugger.IsAttached)
                {
                    logger.Log(LogSeverity.Important, "Attaching the debugger to the host.");
                    attachResult = debugger.AttachToProcess(currentProcess);
                    if (attachResult == AttachDebuggerResult.CouldNotAttach)
                    {
                        logger.Log(LogSeverity.Warning, "Could not attach debugger to the host.");
                    }
                }

                RunEndpoint(logger);
            }
            finally
            {
                if (attachResult == AttachDebuggerResult.Attached)
                {
                    logger.Log(LogSeverity.Important, "Detaching the debugger from the host.");
                    DetachDebuggerResult detachResult = debugger.DetachFromProcess(currentProcess);
                    if (detachResult == DetachDebuggerResult.CouldNotDetach)
                    {
                        logger.Log(LogSeverity.Warning, "Could not detach debugger from the host.");
                    }
                }
            }
        }
        public void GetDebugger_WhenArgumentsValid_ReturnsADebugger()
        {
            var manager = new DefaultDebuggerManager();

            Assert.IsNotNull(manager.GetDebugger(new DebuggerSetup(), MockRepository.GenerateStub <ILogger>()));
        }
        public void GetDebugger_WhenLoggerIsNull_Throws()
        {
            var manager = new DefaultDebuggerManager();

            Assert.Throws <ArgumentNullException>(() => manager.GetDebugger(new DebuggerSetup(), null));
        }
        public void GetDebugger_WhenDebuggerSetupIsNull_Throws()
        {
            var manager = new DefaultDebuggerManager();

            Assert.Throws <ArgumentNullException>(() => manager.GetDebugger(null, MockRepository.GenerateStub <ILogger>()));
        }