Beispiel #1
0
        public void WatchBasic(ITestSettings settings)
        {
            this.TestPurpose("Evaluate some expressions in watch.");
            this.WriteSettings(settings);

            IDebuggee debuggee = SinkHelper.Open(this, settings.CompilerSettings, DebuggeeMonikers.KitchenSink.Expression);

            using (IDebuggerRunner runner = CreateDebugAdapterRunner(settings))
            {
                this.Comment("Configure launch");
                runner.Launch(settings.DebuggerSettings, debuggee, "-fExpression");

                this.Comment("Set a line breakpoints so that we can stop.");
                runner.SetBreakpoints(debuggee.Breakpoints(SinkHelper.Expression, 31));

                this.Comment("To start debugging and break");
                runner.Expects.StoppedEvent(StoppedReason.Breakpoint).AfterConfigurationDone();

                using (IThreadInspector threadInspector = runner.GetThreadInspector())
                {
                    IFrameInspector currentFrame = threadInspector.Stack.First();

                    this.Comment("To evaluate variables and functions in watch.");
                    string evalMyInt = currentFrame.Evaluate("myint-=100", EvaluateContext.Watch);
                    currentFrame.AssertEvaluateAsChar("mychar", EvaluateContext.Watch, 'A');
                    string evalMyBool = currentFrame.Evaluate("mybool", EvaluateContext.Watch);
                    currentFrame.AssertEvaluateAsWChar("mywchar", EvaluateContext.Watch, 'z');
                    currentFrame.AssertEvaluateAsDouble("mydouble", EvaluateContext.Watch, 321);
                    currentFrame.AssertEvaluateAsFloat("myfloat", EvaluateContext.Watch, 299);
                    string evalFuncMaxInt = currentFrame.Evaluate("Test::max(myint,1)", EvaluateContext.Watch);
                    currentFrame.AssertEvaluateAsDouble("Test::max(mydouble,0.0)-321.0", EvaluateContext.Watch, 0);

                    Assert.Equal("0", evalMyInt);
                    Assert.Equal("true", evalMyBool);
                    Assert.Equal("1", evalFuncMaxInt);
                }

                this.Comment("Run to completion");
                runner.Expects.TerminatedEvent().AfterContinue();

                runner.DisconnectAndVerify();
            }
        }