예제 #1
0
        public async Task BreakpointHit_FunctionEvaluation()
        {
            string condition = "Hello() == \"Hello, World!\"";

            using (var app = StartTestApp(debugEnabled: true, methodEvaluation: true))
            {
                Debuggee           debuggee   = Polling.GetDebuggee(app.Module, app.Version);
                DebuggerBreakpoint breakpoint = SetBreakpointAndSleep(
                    debuggee.Id, TestApplication.MainClass,
                    TestApplication.LoopMiddle, condition);

                // Checks that the breakpoint has a condition.
                Assert.Equal(breakpoint.Condition, condition);

                using (HttpClient client = new HttpClient())
                {
                    await client.GetAsync(TestApplication.GetLoopUrl(app, 10));
                }

                DebuggerBreakpoint newBp = Polling.GetBreakpoint(debuggee.Id, breakpoint.Id);

                // Checks that the breakpoint has been hit.
                Assert.True(newBp.IsFinalState);
                // Checks that "i" is 0 when the breakpoint is hit.
                Debugger.V2.StackFrame firstFrame = newBp.StackFrames[0];
                DebuggerVariable       iVariable  = firstFrame.Locals.First(local => local.Name == "i");
                Assert.Equal("0", iVariable.Value);
            }
        }
예제 #2
0
        public async Task TestCollection(string collectionName)
        {
            using (var app = StartTestApp(debugEnabled: true))
            {
                var    debuggee      = Polling.GetDebuggee(app.Module, app.Version);
                var    breakpoint    = SetBreakpointAndSleep(debuggee.Id, TestApplication.MainClass, TestApplication.EchoBottomLine);
                string collectionKey = "RandomKey";

                using (HttpClient client = new HttpClient())
                {
                    await client.GetAsync($"{app.AppUrlEcho}/{collectionKey}");
                }

                var newBp = Polling.GetBreakpoint(debuggee.Id, breakpoint.Id);

                // Check that the breakpoint has been hit.
                Assert.True(newBp.IsFinalState);

                // Checks that the first frame of the breakpoint contains collection.
                DebuggerVariable collection = newBp.StackFrames[0].Locals.FirstOrDefault(localVar
                                                                                         => localVar.Name == $"test{collectionName}");
                Assert.NotNull(collection);

                Assert.Equal(6, collection.Members.Count);
                DebuggerVariable collectionCount = collection.Members.FirstOrDefault(member => member.Name == "Count");
                Assert.NotNull(collectionCount);
                Assert.Equal("5", collectionCount.Value);
                for (int i = 0; i < 5; i += 1)
                {
                    DebuggerVariable item = collection.Members.FirstOrDefault(member => member.Name == $"[{i}]");
                    Assert.NotNull(item);
                    if (collectionName == "Dictionary")
                    {
                        DebuggerVariable key   = item.Members.FirstOrDefault(member => member.Name == "key");
                        DebuggerVariable value = item.Members.FirstOrDefault(member => member.Name == "value");
                        Assert.NotNull(key);
                        Assert.NotNull(value);
                        Assert.Equal($"Key{collectionKey}{i}", key.Value);
                        Assert.Equal($"{i}", value.Value);
                    }
                    else
                    {
                        Assert.Equal($"{collectionName}{collectionKey}{i}", item.Value);
                    }
                }
            }
        }
예제 #3
0
        public async Task BreakpointHit_Constant()
        {
            using (var app = StartTestApp(debugEnabled: true))
            {
                var debuggee   = Polling.GetDebuggee(app.Module, app.Version);
                var breakpoint = SetBreakpointAndSleep(debuggee.Id, TestApplication.MainClass,
                                                       TestApplication.ConstantBottomLine);

                using (HttpClient client = new HttpClient())
                {
                    await client.GetAsync($"{app.AppConstant}");
                }

                var newBp = Polling.GetBreakpoint(debuggee.Id, breakpoint.Id);

                Assert.True(newBp.IsFinalState);

                // Only check the first one as it's the only one with information we care about.
                var stackframe = newBp.StackFrames[0];

                // Get 'this' arg for the class values so we can check the constant fields.
                DebuggerVariable thisArg = stackframe.Arguments.Where(l => l.Name == "this").Single();
                Assert.Equal(typeof(TestApp.MainController).ToString(), thisArg.Type);

                // Check the constant fields.
                var fields = thisArg.Members;

                // Check constant int field.
                DebuggerVariable constantIntField = fields.Where(m => m.Name == "ConstantInt").Single();
                Assert.Equal(typeof(System.Int32).ToString(), constantIntField.Type);
                Assert.Equal("10", constantIntField.Value);

                // Check the constant string field.
                DebuggerVariable constantStringField = fields.Where(m => m.Name == "ConstantString").Single();
                Assert.Equal(typeof(System.String).ToString(), constantStringField.Type);
                Assert.Equal("ConstantStringField", constantStringField.Value);

                // Check the constant enum field.
                DebuggerVariable constantEnumField = fields.Where(m => m.Name == "Tuesday").Single();
                Assert.Equal(typeof(DayOfWeek).ToString(), constantEnumField.Type);
                Assert.Equal("Tuesday", constantEnumField.Value);

                // Check the constant variables.
                var locals = stackframe.Locals;

                // Check the constant integer.
                DebuggerVariable constantIntVar = locals.Where(m => m.Name == "constInt").Single();
                Assert.Equal(typeof(System.Int32).ToString(), constantIntVar.Type);
                Assert.Equal("5", constantIntVar.Value);

                // Check the constant double.
                DebuggerVariable constantDoubleVar = locals.Where(m => m.Name == "constDouble").Single();
                Assert.Equal(typeof(System.Double).ToString(), constantDoubleVar.Type);
                Assert.Equal("3.500000", constantDoubleVar.Value);

                // Check the constant string.
                DebuggerVariable constantStringVar = locals.Where(m => m.Name == "constString").Single();
                Assert.Equal(typeof(System.String).ToString(), constantStringVar.Type);
                Assert.Equal("ConstString", constantStringVar.Value);

                // Check the constant enum.
                DebuggerVariable constantEnumVar = locals.Where(m => m.Name == "constEnum").Single();
                Assert.Equal(typeof(DayOfWeek).ToString(), constantEnumVar.Type);
                Assert.Equal("Monday", constantEnumVar.Value);
            }
        }