public void SetUp() { logSpy = new LogSpy(); logSpy.Attach(); taskContext = new JoinableTaskContext(); returnObjectMock = Substitute.For <SbCommandReturnObject>(); returnObjectMock.GetDescription().Returns(COMMAND_DESCRIPTION); commandInterpreterMock = Substitute.For <SbCommandInterpreter>(); commandInterpreterMock.WhenForAnyArgs(x => x.HandleCommand(DUMMY_COMMAND, out returnObjectMock)).Do(x => x[1] = returnObjectMock); debuggerMock = Substitute.For <SbDebugger>(); debuggerMock.GetCommandInterpreter().Returns(commandInterpreterMock); commandWindowText = ""; commandWindowMock = Substitute.For <IVsCommandWindow>(); commandWindowMock.Print(Arg.Do <string>(x => commandWindowText += x)); commandWindowWriter = new CommandWindowWriter(taskContext, commandWindowMock); shell = new YetiVSI.LLDBShell.LLDBShell(taskContext, commandWindowWriter); shell.AddDebugger(debuggerMock); }
void SetHandleCommandReturnValue(SbCommandInterpreter mockCommandInterpreter, string command, ReturnStatus returnStatus, SbCommandReturnObject returnObject) { SbCommandReturnObject _; mockCommandInterpreter.HandleCommand(command, out _).Returns(x => { x[1] = returnObject; return(returnStatus); }); }
// Prints the output from the |commandResult| to the Command Window. If a Command Window // doesn't exist the output is printed to the logs instead. private void PrintCommandResult(SbCommandReturnObject commandResult) { taskContext.ThrowIfNotOnMainThread(); if (commandResult == null) { string errorMessage = "ERROR: The LLDB Shell command failed to return a result."; Trace.WriteLine(errorMessage); commandWindowWriter.PrintLine(errorMessage); return; } commandWindowWriter.PrintLine(commandResult.GetDescription()); }
public void SetUp() { searchLog = new StringWriter(); mockBinaryFileUtil = Substitute.For <IBinaryFileUtil>(); mockSuccessCommandReturnObject = Substitute.For <SbCommandReturnObject>(); mockSuccessCommandReturnObject.GetOutput().Returns(LLDB_OUTPUT); mockSuccessCommandReturnObject.GetDescription().Returns("Success: " + LLDB_OUTPUT); mockSuccessCommandReturnObject.Succeeded().Returns(true); mockCommandInterpreter = Substitute.For <SbCommandInterpreter>(); SetHandleCommandReturnValue(mockCommandInterpreter, COMMAND_WITH_MODULE_PATH, ReturnStatus.SuccessFinishResult, mockSuccessCommandReturnObject); mockPlatformFileSpec = Substitute.For <SbFileSpec>(); mockPlatformFileSpec.GetDirectory().Returns(PLATFORM_DIRECTORY); mockPlatformFileSpec.GetFilename().Returns(BINARY_FILENAME); mockSymbolFileSpec = Substitute.For <SbFileSpec>(); mockSymbolFileSpec.GetDirectory().Returns(""); mockSymbolFileSpec.GetFilename().Returns(SYMBOL_FILE_NAME); mockBinaryFileSpec = Substitute.For <SbFileSpec>(); mockBinaryFileSpec.GetDirectory().Returns(BINARY_DIRECTORY); mockBinaryFileSpec.GetFilename().Returns(BINARY_FILENAME); mockModuleFileFinder = Substitute.For <IModuleFileFinder>(); SetFindFileReturnValue(PATH_IN_STORE); mockModuleUtil = Substitute.For <ILldbModuleUtil>(); mockModuleUtil.HasSymbolsLoaded(Arg.Any <SbModule>()).Returns(false); symbolLoader = new SymbolLoader(mockModuleUtil, mockBinaryFileUtil, mockModuleFileFinder, mockCommandInterpreter); symbolFileInStore = Substitute.For <IFileReference>(); symbolFileInStore.IsFilesystemLocation.Returns(true); symbolFileInStore.Location.Returns(PATH_IN_STORE); logSpy = new LogSpy(); logSpy.Attach(); }
public ReturnStatus HandleCommand(string command, out SbCommandReturnObject result) { result = null; HandleCommandResponse response = null; if (connection.InvokeRpc(() => { response = client.HandleCommand( new HandleCommandRequest { Command = command, Interpreter = grpcSbInterpreter }); })) { if (response.ReturnObject != null && response.ReturnObject.Id != 0) { result = returnObjectFactory.Create(connection, response.ReturnObject); return(response.ReturnStatus.ConvertTo <ReturnStatus>()); } } return(ReturnStatus.Invalid); }
public ReturnStatus HandleCommand(string command, out SbCommandReturnObject result) { handledCommands.Add(command); result = new SbCommandReturnObjectStub(true); return(ReturnStatus.SuccessFinishResult); }