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); }
public void ExecuteCommandWithMultipleDebuggers() { var secondDebuggerMock = Substitute.For <SbDebugger>(); ClearDebuggers(); shell.AddDebugger(debuggerMock); shell.AddDebugger(secondDebuggerMock); shell.ExecuteCommand(DUMMY_COMMAND); Assert.That(commandWindowText, Does.Contain("ERROR")); Assert.That(logSpy.GetOutput(), Does.Contain("ERROR")); debuggerMock.DidNotReceive().GetCommandInterpreter(); secondDebuggerMock.DidNotReceive().GetCommandInterpreter(); commandInterpreterMock.DidNotReceiveWithAnyArgs().HandleCommand(Arg.Any <string>(), out dummyReturnObject); Assert.That(logSpy.GetOutput(), Does.Contain(DUMMY_COMMAND)); }
public void ExecuteCommandWithNoCommandWindow() { // CommandWindowWriter grabs the SVsCommandWindow once in the constructor. If we change // the service provide mock we need to create a new CommandwindowWriter to pick up the // change. commandWindowWriter = new CommandWindowWriter(taskContext, null); shell = new YetiVSI.LLDBShell.LLDBShell(taskContext, commandWindowWriter); shell.AddDebugger(debuggerMock); shell.ExecuteCommand(DUMMY_COMMAND); Assert.That(logSpy.GetOutput(), Does.Contain(COMMAND_DESCRIPTION)); Assert.That(logSpy.GetOutput(), Does.Contain(DUMMY_COMMAND)); }