public void AttachToCoreWithEmptyTargetSucceeds()
        {
            int                   calls                = 0;
            SshTarget             expectedTarget       = null;
            var                   attachReason         = enum_ATTACH_REASON.ATTACH_REASON_LAUNCH;
            IDebugSessionLauncher debugSessionLauncher =
                CreateConfiguredDebugSessionLauncher(expectedTarget, x => {
                calls++;
                var attachedProgram = Substitute.For <ILldbAttachedProgram>();
                return(Task.FromResult(attachedProgram));
            });
            IDebugSessionLauncherFactory debugSessionLauncherFactory =
                CreateDebugSessionLauncherFactory(debugSessionLauncher);
            IGgpDebugEngine debugEngine = CreateGgpDebugEngine(debugSessionLauncherFactory);
            var             debugPort   = Substitute.For <IDebugPort2>();

            debugEngine.LaunchSuspended("", debugPort, _exePath, null, null, null, null,
                                        enum_LAUNCH_FLAGS.LAUNCH_DEBUG, 0, 0, 0, null,
                                        out IDebugProcess2 _);
            var rgpPrograms     = new[] { Substitute.For <IDebugProgram2>() };
            var rgpProgramNodes = new[] { Substitute.For <IDebugProgramNode2>() };

            int result =
                debugEngine.Attach(rgpPrograms, rgpProgramNodes, _celtPrograms, null, attachReason);

            Assert.Multiple(() => {
                debugPort.Received().GetProcess(Arg.Any <AD_PROCESS_ID>(), out _);
                Assert.That(result, Is.EqualTo(VSConstants.S_OK));
                Assert.That(calls, Is.EqualTo(1));
            });
        }
        /// <summary>
        /// Get IDebugSessionLauncherFactory instance that returns specified sessionLauncher when
        /// called Create() with any parameters.
        /// </summary>
        IDebugSessionLauncherFactory CreateDebugSessionLauncherFactory(
            IDebugSessionLauncher sessionLauncher)
        {
            var debugSessionLauncherFactory = Substitute.For <IDebugSessionLauncherFactory>();

            debugSessionLauncherFactory.Create(Arg.Any <IDebugEngine3>(),
                                               Arg.Any <YetiVSI.DebugEngine.DebugEngine.
                                                        LaunchOption>(), Arg.Any <string>(),
                                               Arg.Any <string>(), Arg.Any <string>(),
                                               Arg.Any <IVsiGameLaunch>())
            .Returns((x) => sessionLauncher);
            return(debugSessionLauncherFactory);
        }
        public void RemoteDeployNotCalledDuringAttachToCore(enum_ATTACH_REASON attachReason)
        {
            var gamelet = new Gamelet {
                IpAddr = _gameletIp
            };
            var expectedTarget = new SshTarget(gamelet);
            IDebugSessionLauncher debugSessionLauncher =
                CreateConfiguredDebugSessionLauncher(expectedTarget, x => {
                var attachedProgram = Substitute.For <ILldbAttachedProgram>();
                return(Task.FromResult(attachedProgram));
            });

            IDebugSessionLauncherFactory debugSessionLauncherFactory =
                CreateDebugSessionLauncherFactory(debugSessionLauncher);
            int calls        = 0;
            var remoteDeploy = Substitute.For <IRemoteDeploy>();

            remoteDeploy.DeployLldbServerAsync(expectedTarget, Arg.Any <IAction>()).Returns(x => {
                calls++;
                return(Task.CompletedTask);
            });
            IGgpDebugEngine debugEngine =
                CreateGgpDebugEngine(debugSessionLauncherFactory, remoteDeploy);
            IDebugPort2 debugPort = CreateDebugPort(gamelet);
            string      options   = null;

            debugEngine.LaunchSuspended("", debugPort, _exePath, null, null, null, options,
                                        enum_LAUNCH_FLAGS.LAUNCH_DEBUG, 0, 0, 0, null,
                                        out IDebugProcess2 _);
            IDebugProgram2 program = CreateDebugProgram(debugPort);

            IDebugProgram2[] rgpPrograms = { program };
            var rgpProgramNodes          = new[] { Substitute.For <IDebugProgramNode2>() };

            debugEngine.Attach(rgpPrograms, rgpProgramNodes, _celtPrograms, null, attachReason);

            Assert.That(calls, Is.EqualTo(0));
        }
 Task <ILldbAttachedProgram> LaunchAsync(IDebugSessionLauncher launcher)
 {
     return(launcher.LaunchAsync(_task, _process, _programId, _pid, _debuggerOptions,
                                 _libPaths, _grpcConnection, 10200, _gameletIpAddress,
                                 _gameletPort, _callback));
 }