Пример #1
0
        public void Convert_StackdriverBreakpointWithError()
        {
            var breakpoint = new Breakpoint
            {
                Id       = _id,
                Location = new SourceLocation
                {
                    Path = _path,
                    Line = _line
                },
                CreateTime = Timestamp.FromDateTime(DateTime.UtcNow),
                FinalTime  = Timestamp.FromDateTime(DateTime.UtcNow.AddSeconds(10)),
                Status     = new Status
                {
                    Message = "This is an error",
                    Iserror = true
                }
            };

            StackdriverBreakpoint sdBreakpoint = breakpoint.Convert();

            Assert.Equal(_id, sdBreakpoint.Id);
            Assert.Equal(_path.Replace('\\', '/'), sdBreakpoint.Location.Path);
            Assert.Equal(_line, sdBreakpoint.Location.Line);
            Assert.Equal(breakpoint.CreateTime, sdBreakpoint.CreateTime);
            Assert.Equal(breakpoint.FinalTime, sdBreakpoint.FinalTime);
            Assert.Equal(breakpoint.Status.Message, sdBreakpoint.Status.Description.Format);
            Assert.Equal(breakpoint.Status.Iserror, sdBreakpoint.Status.IsError);
        }
Пример #2
0
        /// <summary>
        /// Blocks and reads a breakpoint from the <see cref="IBreakpointServer"/>
        /// and then sends the sends the breakpoint to the debugger API.
        /// </summary>
        internal override void MainAction()
        {
            Breakpoint readBreakpoint = _server.ReadBreakpointAsync().Result;

            if (readBreakpoint.KillServer)
            {
                _cts.Cancel();
                return;
            }
            StackdriverBreakpoint breakpoint = readBreakpoint.Convert();

            breakpoint.IsFinalState = true;
            _client.UpdateBreakpoint(breakpoint);
        }
Пример #3
0
        public void MainAction()
        {
            var breakpoint = new Breakpoint
            {
                Id       = "some-id",
                Location = new SourceLocation
                {
                    Line = 1,
                    Path = "some-path"
                }
            };

            _mockBreakpointServer.Setup(s => s.ReadBreakpointAsync(It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(breakpoint));
            _server.MainAction();

            var sdBreakpoint = breakpoint.Convert();

            sdBreakpoint.IsFinalState = true;
            _mockDebuggerClient.Verify(c => c.UpdateBreakpoint(sdBreakpoint), Times.Once);
        }
        /// <summary>
        /// Blocks and reads a breakpoint from the <see cref="IBreakpointServer"/>
        /// and then sends the sends the breakpoint to the debugger API.
        /// </summary>
        internal override void MainAction()
        {
            Breakpoint readBreakpoint = _server.ReadBreakpointAsync().Result;

            if (readBreakpoint.KillServer)
            {
                _cts.Cancel();
                return;
            }
            StackdriverBreakpoint breakpoint = readBreakpoint.Convert();

            if (breakpoint.Action == StackdriverBreakpoint.Types.Action.Log)
            {
                _loggingClient.WriteLogEntry(breakpoint);
            }
            else
            {
                breakpoint.IsFinalState = true;
            }
            _debuggerClient.UpdateBreakpoint(breakpoint);
        }
Пример #5
0
        public void Convert_StackdriverBreakpoint()
        {
            var breakpoint = new Breakpoint
            {
                Id       = _id,
                Location = new SourceLocation
                {
                    Path = _path,
                    Line = _line
                },
                CreateTime  = Timestamp.FromDateTime(DateTime.UtcNow),
                FinalTime   = Timestamp.FromDateTime(DateTime.UtcNow.AddSeconds(10)),
                StackFrames =
                {
                    new StackFrame
                    {
                        MethodName = "method-one",
                        Location   = new SourceLocation
                        {
                            Path = "path",
                            Line = 10,
                        }
                    },
                    new StackFrame
                    {
                        MethodName = "method-two",
                        Location   = new SourceLocation
                        {
                            Path = "path",
                            Line = 11,
                        },
                        Arguments =
                        {
                            new Variable(),
                            new Variable(),
                        },
                    }
                },
                EvaluatedExpressions =
                {
                    new Variable()
                    {
                        Name = "first-expression"
                    },
                    new Variable()
                    {
                        Name = "second-expression"
                    }
                },
                LogMessageFormat = "Log Message Format",
                LogLevel         = Breakpoint.Types.LogLevel.Warning
            };

            var sdBreakpoint = breakpoint.Convert();

            Assert.Equal(_id, sdBreakpoint.Id);
            Assert.Equal(_path.Replace('\\', '/'), sdBreakpoint.Location.Path);
            Assert.Equal(_line, sdBreakpoint.Location.Line);
            Assert.Equal(breakpoint.CreateTime, sdBreakpoint.CreateTime);
            Assert.Equal(breakpoint.FinalTime, sdBreakpoint.FinalTime);
            Assert.Equal(2, sdBreakpoint.StackFrames.Count);
            Assert.Single(sdBreakpoint.StackFrames.Where(sf => sf.Function.Equals("method-one")));
            var sfTwo = sdBreakpoint.StackFrames.Where(sf => sf.Function.Equals("method-two"));

            Assert.Equal(2, sfTwo.Single().Arguments.Count);
            Assert.Equal(2, sdBreakpoint.EvaluatedExpressions.Count);
            Assert.Single(
                sdBreakpoint.EvaluatedExpressions.Where(ee => ee.Name.Equals("first-expression")));
            Assert.Single(
                sdBreakpoint.EvaluatedExpressions.Where(ee => ee.Name.Equals("second-expression")));
            Assert.Equal(breakpoint.LogMessageFormat, sdBreakpoint.LogMessageFormat);
            Assert.Equal(StackdriverBreakpoint.Types.LogLevel.Warning, sdBreakpoint.LogLevel);
        }