public void WriteBreakpointAsync()
        {
            var breakpoint = new Breakpoint
            {
                Id = "some-id"
            };

            Predicate <byte[]> matcher = (bytesArr) =>
            {
                var bytes = bytesArr.Take(Constants.StartBreakpointMessage.Length);
                Assert.Equal(bytes, Constants.StartBreakpointMessage);

                bytes = bytesArr.Skip(bytesArr.Length - Constants.EndBreakpointMessage.Length);
                Assert.Equal(bytes, Constants.EndBreakpointMessage);

                bytes = bytesArr.Skip(Constants.StartBreakpointMessage.Length).ToArray();
                bytes = bytes.Take(bytes.Count() - Constants.EndBreakpointMessage.Length);
                Assert.Equal(bytes, breakpoint.ToByteArray());

                return(true);
            };

            _pipeMock.Setup(p => p.WriteAsync(Match.Create(matcher), _cts.Token));
            _server.WriteBreakpointAsync(breakpoint, _cts.Token);
            _pipeMock.VerifyAll();
            _pipeMock.Verify(p => p.WriteAsync(It.IsAny <byte[]>(), _cts.Token), Times.Once());
        }
        private byte[] CreateBreakpointMessage(Breakpoint breakpoint)
        {
            List <byte> bytes = new List <byte>();

            bytes.AddRange(Constants.StartBreakpointMessage);
            bytes.AddRange(breakpoint.ToByteArray());
            bytes.AddRange(Constants.EndBreakpointMessage);
            return(bytes.ToArray());
        }
        public async Task ReadBreakpointAsync_InvalidBreakpoint()
        {
            var breakpoint = new Breakpoint
            {
                Id = "some-id-1"
            };
            var breakpointMessage = breakpoint.ToByteArray().ToList();

            breakpointMessage.AddRange(Constants.EndBreakpointMessage);

            _pipeMock.Setup(p => p.ReadAsync(_cts.Token)).Returns(Task.FromResult(breakpointMessage.ToArray()));

            await Assert.ThrowsAsync <InvalidOperationException>
                (async() => await _server.ReadBreakpointAsync(_cts.Token));

            _pipeMock.Verify(p => p.ReadAsync(_cts.Token), Times.Exactly(1));
        }