示例#1
0
        private void DoTest(bool expectedResult)
        {
            string pipeId            = Guid.NewGuid().ToString();
            int    debuggeeProcessId = 2017;

            // ReSharper disable once UnusedVariable
            var host = new DebuggerAttacherServiceHost(pipeId, MockDebuggerAttacher.Object, MockLogger.Object);

            try
            {
                host.Open();

                var client = new MessageBasedDebuggerAttacher(pipeId, Timeout, MockLogger.Object);

                client.AttachDebugger(debuggeeProcessId, DebuggerEngine.Native).Should().Be(expectedResult);

                MockDebuggerAttacher.Verify(a => a.AttachDebugger(It.Is <int>(processId => processId == debuggeeProcessId), It.IsAny <DebuggerEngine>()),
                                            Times.Once);

                host.Close();
            }
            catch (CommunicationException)
            {
                host.Abort();
                throw;
            }
        }
示例#2
0
        public void AttachDebugger_NoPipeAvailable_ErrorOutputGenerated()
        {
            var client = new MessageBasedDebuggerAttacher(Guid.NewGuid().ToString(), Timeout, MockLogger.Object);

            client.AttachDebugger(2017, DebuggerEngine.Native).Should().BeFalse();

            MockLogger.Verify(l => l.LogError(It.Is <string>(s => s.Contains("EndpointNotFoundException"))), Times.Once);
        }
        public void AttachDebugger_NoPipeAvailable_ErrorOutputGenerated()
        {
            var client = new MessageBasedDebuggerAttacher(Guid.NewGuid().ToString(), Timeout, MockLogger.Object);

            client.AttachDebugger(2017).Should().BeFalse();

            MockLogger.Verify(l => l.LogError(It.Is <string>(s => s.Contains("Could not connect to NamedPipe"))), Times.Once);
        }
        private void DoTest(bool expectedResult)
        {
            string pipeId            = Guid.NewGuid().ToString();
            int    debuggeeProcessId = 2017;

            // ReSharper disable once UnusedVariable
            using (var service = new DebuggerAttacherService(pipeId, MockDebuggerAttacher.Object, MockLogger.Object))
            {
                var client = new MessageBasedDebuggerAttacher(pipeId, Timeout, MockLogger.Object);

                client.AttachDebugger(debuggeeProcessId).Should().Be(expectedResult);

                MockDebuggerAttacher.Verify(a => a.AttachDebugger(It.Is <int>(processId => processId == debuggeeProcessId)),
                                            Times.Once);
            }
        }