public void ProcessEvaluateResponseWithReferenceError() { // Arrange const int commandId = 3; var resultFactoryMock = new Mock <IEvaluationResultFactory>(); resultFactoryMock.Setup(factory => factory.Create(It.IsAny <INodeVariable>())); const string expression = "hello"; var stackFrame = new NodeStackFrame(0); var evaluateCommand = new EvaluateCommand(commandId, resultFactoryMock.Object, expression, stackFrame); Exception exception = null; // Act try { evaluateCommand.ProcessResponse(SerializationTestData.GetEvaluateResponseWithReferenceError()); } catch (Exception e) { exception = e; } // Assert Assert.IsNotNull(exception); Assert.IsInstanceOfType(exception, typeof(DebuggerCommandException)); Assert.AreEqual("ReferenceError: hello is not defined", exception.Message); Assert.IsNull(evaluateCommand.Result); resultFactoryMock.Verify(factory => factory.Create(It.IsAny <INodeVariable>()), Times.Never); }
public void ProcessEvaluateResponse() { // Arrange const int commandId = 3; var resultFactoryMock = new Mock <IEvaluationResultFactory>(); resultFactoryMock.Setup(factory => factory.Create(It.IsAny <INodeVariable>())) .Returns(() => new NodeEvaluationResult(0, null, null, null, null, null, NodeExpressionType.None, null)); const string expression = "expression"; var stackFrame = new NodeStackFrame(0); var evaluateCommand = new EvaluateCommand(commandId, resultFactoryMock.Object, expression, stackFrame); // Act evaluateCommand.ProcessResponse(SerializationTestData.GetEvaluateResponse()); // Assert Assert.AreEqual(commandId, evaluateCommand.Id); Assert.IsNotNull(evaluateCommand.Result); resultFactoryMock.Verify(factory => factory.Create(It.IsAny <INodeVariable>()), Times.Once); }