public async Task ChangeLldbEvalFlagInRuntimeAsync()
        {
            _optionPageGrid.ExpressionEvaluationEngine = ExpressionEvaluationEngineFlag.LLDB;

            RemoteValue mockVariable = CreateMockVariable();
            var         natvisScope  = new NatvisScope();

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

            await mockVariable.DidNotReceiveWithAnyArgs().EvaluateExpressionLldbEvalAsync(
                Arg.Any <string>());

            await mockVariable.Received(1).EvaluateExpressionAsync(Arg.Is("2 + 2"));

            mockVariable.ClearReceivedCalls();

            // Change the configuration flag
            _optionPageGrid.ExpressionEvaluationEngine = ExpressionEvaluationEngineFlag.LLDB_EVAL;

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

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

            mockVariable.ClearReceivedCalls();

            // Change the configuration flag back to LLDB
            _optionPageGrid.ExpressionEvaluationEngine = ExpressionEvaluationEngineFlag.LLDB;

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

            await mockVariable.DidNotReceiveWithAnyArgs().EvaluateExpressionLldbEvalAsync(
                Arg.Any <string>());

            await mockVariable.Received(1).EvaluateExpressionAsync(Arg.Is("4 + 4"));
        }
        public async Task LldbEvalDisabledAsync()
        {
            _optionPageGrid.ExpressionEvaluationEngine = ExpressionEvaluationEngineFlag.LLDB;

            RemoteValue mockVariable = CreateMockVariable();
            await _evaluator.EvaluateExpressionAsync("expr", _varInfoFactory.Create(mockVariable),
                                                     new NatvisScope(), "result");

            await mockVariable.DidNotReceiveWithAnyArgs().EvaluateExpressionLldbEvalAsync(
                Arg.Any <string>());

            mockVariable.Received(1).GetValueForExpressionPath(Arg.Is(".expr"));
            await mockVariable.Received(1).EvaluateExpressionAsync(Arg.Is("expr"));
        }
        public void LldbEvalWithoutFallback(LldbEvalErrorCode lldbEvalErrorCode)
        {
            _optionPageGrid.ExpressionEvaluationEngine = ExpressionEvaluationEngineFlag.LLDB_EVAL;

            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(
                    "expr", _varInfoFactory.Create(mockVariable), new NatvisScope(), "result"));

            mockVariable.DidNotReceiveWithAnyArgs().GetValueForExpressionPath(Arg.Any <string>());

            Assert.That(exception.Message, Does.Contain("the error message"));
        }
        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"));
        }