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));
            });
        }
        public void AttachNeedsNumProgramsToEqual1([Values] enum_ATTACH_REASON attachReason)
        {
            IGgpDebugEngine debugEngine = CreateGgpDebugEngine();

            int result = debugEngine.Attach(null, null, 2, null, attachReason);

            Assert.That(result, Is.EqualTo(VSConstants.E_INVALIDARG));
        }
        public void AttachNotImplementedForAutoAttach()
        {
            IGgpDebugEngine debugEngine = CreateGgpDebugEngine();

            int result = debugEngine.Attach(null, null, _celtPrograms, null,
                                            enum_ATTACH_REASON.ATTACH_REASON_AUTO);

            Assert.That(result, Is.EqualTo(VSConstants.E_NOTIMPL));
        }
        public void AttachToGameletWithUnknownTargetFailsAsUserAbortedOperation()
        {
            var gamelet = new Gamelet {
                IpAddr = ""
            };
            var             attachReason = enum_ATTACH_REASON.ATTACH_REASON_USER;
            IGgpDebugEngine debugEngine  = CreateGgpDebugEngine();

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

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

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

            Assert.That(result, Is.EqualTo(VSConstants.E_ABORT));
        }
        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));
        }
 public int Attach(IDebugProgram2[] rgpPrograms, IDebugProgramNode2[] rgpProgramNodes,
                   uint celtPrograms, IDebugEventCallback2 pCallback, enum_ATTACH_REASON dwReason)
 {
     return(debugEngine.Attach(rgpPrograms, rgpProgramNodes, celtPrograms, pCallback,
                               dwReason));
 }