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> /// Generate light-weight version of <see cref="DebugEngineFactoryCompRoot"/> /// with most methods and properties mocked for testing. /// </summary> /// <param name="factory"><see cref="IDebugSessionLauncherFactory"/> instance to use /// instead of created one. /// </param> /// <param name="remoteDeploy"><see cref="IRemoteDeploy"/> instance to use during the /// deployment process.</param> /// <param name="gameLauncher">Game launcher.</param> public DebugEngineFactoryCompRootStub(IDebugSessionLauncherFactory factory, IRemoteDeploy remoteDeploy, IGameLauncher gameLauncher) { _debugSessionLauncherFactory = factory; _remoteDeploy = remoteDeploy; _gameLauncher = gameLauncher; }
IGgpDebugEngine CreateGgpDebugEngine( IDebugSessionLauncherFactory debugSessionLauncherFactory = null, IRemoteDeploy remoteDeploy = null) { DebugEngineFactoryCompRootStub compRoot = CreateEngineFactoryCompRoot( debugSessionLauncherFactory, remoteDeploy ?? Substitute.For <IRemoteDeploy>()); IDebugEngineFactory factory = compRoot.CreateDebugEngineFactory(); return(factory.Create(null)); }
DebugEngineFactoryCompRootStub CreateEngineFactoryCompRoot( IDebugSessionLauncherFactory debugSessionLauncherFactory, IRemoteDeploy remoteDeploy) { var compRoot = new DebugEngineFactoryCompRootStub( debugSessionLauncherFactory, remoteDeploy, Substitute.For <IGameLauncher>()); _metrics = Substitute.For <IMetrics>(); _metrics.NewDebugSessionId().Returns(_debugSessionId); ISessionNotifier sessionNotifier = Substitute.For <ISessionNotifier>(); SLLDBShell lldbShell = TestDummyGenerator.Create <SLLDBShell>(); var vsiService = new YetiVSIService(OptionPageGrid.CreateForTesting()); var vsOutputWindow = new OutputWindowStub(); var symbolSettingsManager = Substitute.For <IVsDebuggerSymbolSettingsManager120A>(); compRoot.ServiceManager = new ServiceManagerStub(_metrics, lldbShell, vsiService, vsOutputWindow, symbolSettingsManager, sessionNotifier); return(compRoot); }
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)); }