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 async Task LldbEvalWithContextVarsAsync()
        {
            _optionPageGrid.ExpressionEvaluationEngine =
                ExpressionEvaluationEngineFlag.LLDB_EVAL_WITH_FALLBACK;

            RemoteValue mockVariable = CreateMockVariable();

            var natvisScope = new NatvisScope();
            var contextVar  = RemoteValueFakeUtil.CreateSimpleInt("var", 14);

            natvisScope.AddScopedName("var", "$var_0");
            natvisScope.AddContextVariable("$var_0", contextVar);

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

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

            Assert.That(natvisScope.ContextVariables.Count, Is.EqualTo(1));
            Assert.That(natvisScope.ContextVariables.ContainsKey("$var_0"));
            Assert.That(natvisScope.ContextVariables["$var_0"], Is.EqualTo(contextVar));

            await mockVariable.DidNotReceive().EvaluateExpressionAsync(Arg.Any <string>());
        }
        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 UseLldbEvalAsync(ExpressionEvaluationEngineFlag engineFlag)
        {
            _optionPageGrid.ExpressionEvaluationEngine = engineFlag;

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

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

            await mockVariable.Received(1).EvaluateExpressionLldbEvalAsync(
                Arg.Is("2 + 2"), Arg.Is(natvisScope.ContextVariables));
        }
        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"));
        }
        public async Task UseLldbEvalWithConstantSubstituteTokensAsync()
        {
            _optionPageGrid.ExpressionEvaluationEngine = ExpressionEvaluationEngineFlag.LLDB_EVAL;

            RemoteValue mockVariable = CreateMockVariable();

            var natvisScope = new NatvisScope();

            natvisScope.AddScopedName("$T1", "int");
            natvisScope.AddScopedName("$i", "2U");

            await _evaluator.EvaluateExpressionAsync(
                "($T1)3.14 + $i", _varInfoFactory.Create(mockVariable), natvisScope, "result");

            await mockVariable.Received(1).EvaluateExpressionLldbEvalAsync(
                Arg.Is("(int)3.14 + 2U"), Arg.Is(natvisScope.ContextVariables));
        }