示例#1
0
        public async Task LldbEvalWithFallbackAsync(LldbEvalErrorCode lldbEvalErrorCode)
        {
            const string     expressionText = "myVar";
            IDebugExpression expression     = CreateExpression(
                expressionText, ExpressionEvaluationStrategy.LLDB_EVAL_WITH_FALLBACK);

            RemoteValueFake errorValue      = RemoteValueFakeUtil.CreateLldbEvalError(lldbEvalErrorCode);
            RemoteValueFake expressionValue =
                RemoteValueFakeUtil.CreateClass("CustomType", "$17", "23");

            _mockDebuggerStackFrame.EvaluateExpressionLldbEvalAsync(expressionText)
            .Returns(errorValue);
            _mockDebuggerStackFrame.EvaluateExpressionAsync(expressionText)
            .Returns(expressionValue);

            Assert.AreEqual(VSConstants.S_OK,
                            expression.EvaluateSync(0, 0, null, out IDebugProperty2 property));

            Assert.AreEqual(expressionText, GetName(property));
            Assert.AreEqual("CustomType", GetType(property));
            Assert.AreEqual("23", GetValue(property));

            // Make sure that a fallback to the LLDB happened.
            await _mockDebuggerStackFrame.Received(1).EvaluateExpressionLldbEvalAsync(
                Arg.Is(expressionText));

            await _mockDebuggerStackFrame.Received(1).EvaluateExpressionAsync(
                Arg.Is(expressionText));
        }
        public void LldbEvalDontFallbackCommonErrors(LldbEvalErrorCode lldbEvalErrorCode)
        {
            _optionPageGrid.ExpressionEvaluationEngine =
                ExpressionEvaluationEngineFlag.LLDB_EVAL_WITH_FALLBACK;

            RemoteValue mockVariable = CreateMockVariable();
            RemoteValue errorValue   =
                RemoteValueFakeUtil.CreateLldbEvalError(lldbEvalErrorCode, "the error message");

            mockVariable
            .EvaluateExpressionLldbEvalAsync(Arg.Any <string>(),
                                             Arg.Any <IDictionary <string, RemoteValue> >())
            .Returns(errorValue);

            var exception = Assert.ThrowsAsync <ExpressionEvaluationFailed>(
                async() => await _evaluator.EvaluateExpressionAsync(
                    "2 + 2", _varInfoFactory.Create(mockVariable), new NatvisScope(), "result"));

            Assert.That(exception.Message, Does.Contain("the error message"));
        }
示例#3
0
        public async Task LldbEvalWithoutFallbackAsync(LldbEvalErrorCode lldbEvalErrorCode)
        {
            const string     expressionText = "myVar";
            IDebugExpression expression     =
                CreateExpression(expressionText, ExpressionEvaluationStrategy.LLDB_EVAL);

            RemoteValueFake errorValue = RemoteValueFakeUtil.CreateLldbEvalError(lldbEvalErrorCode);

            _mockDebuggerStackFrame.EvaluateExpressionLldbEvalAsync(expressionText)
            .Returns(errorValue);

            Assert.AreEqual(VSConstants.S_OK,
                            expression.EvaluateSync(0, 0, null, out IDebugProperty2 property));

            // Make sure that a fallback to the LLDB didn't happen.
            await _mockDebuggerStackFrame.Received(1).EvaluateExpressionLldbEvalAsync(
                Arg.Is(expressionText));

            await _mockDebuggerStackFrame.DidNotReceive().EvaluateExpressionAsync(
                Arg.Any <string>());
        }
        public async Task LldbEvalWithFallbackAsync(LldbEvalErrorCode lldbEvalErrorCode)
        {
            _optionPageGrid.ExpressionEvaluationEngine =
                ExpressionEvaluationEngineFlag.LLDB_EVAL_WITH_FALLBACK;

            RemoteValue mockVariable = CreateMockVariable();
            RemoteValue errorValue   = RemoteValueFakeUtil.CreateLldbEvalError(lldbEvalErrorCode);
            var         natvisScope  = new NatvisScope();

            mockVariable
            .EvaluateExpressionLldbEvalAsync(Arg.Any <string>(),
                                             Arg.Any <IDictionary <string, RemoteValue> >())
            .Returns(errorValue);

            await _evaluator.EvaluateExpressionAsync("expr", _varInfoFactory.Create(mockVariable),
                                                     natvisScope, "result");

            await mockVariable.Received(1).EvaluateExpressionLldbEvalAsync(
                Arg.Is("expr"), Arg.Is(natvisScope.ContextVariables));

            mockVariable.DidNotReceiveWithAnyArgs().GetValueForExpressionPath(Arg.Any <string>());
            await mockVariable.Received(1).EvaluateExpressionAsync(Arg.Is("expr"));
        }