public void DebuggerAttacherService_AttacherReturnsFalse_AnswerWithoutReason()
 {
     MockDebuggerAttacher
     .Setup(a => a.AttachDebugger(It.IsAny <int>()))
     .Returns(MessageBasedDebuggerAttacherTests.GetAttachDebuggerAction(() => false));
     DoTest("unknown reasons");
 }
Exemplo n.º 2
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;
            }
        }
 public void DebuggerAttacherService_AttacherThrows_AnswerIncludesExceptionMessage()
 {
     MockDebuggerAttacher
     .Setup(a => a.AttachDebugger(It.IsAny <int>()))
     .Returns(MessageBasedDebuggerAttacherTests.GetAttachDebuggerAction(() => { throw new Exception("my message"); }));
     DoTest("my message");
 }
 public void DebuggerAttacherService_ReceivesMessage_AnswersImmediately()
 {
     MockDebuggerAttacher
     .Setup(a => a.AttachDebugger(It.IsAny <int>()))
     .Returns(MessageBasedDebuggerAttacherTests.GetAttachDebuggerAction(() => true));
     DoTest(null);
 }
 public void Setup()
 {
     MockDebuggerAttacher.Reset();
     MockLogger.Reset();
     _messages.Clear();
     _resetEvent = new ManualResetEventSlim(false);
 }
Exemplo n.º 6
0
        public void AttachDebugger_AttachingThrows_ErrorOutputGenerated()
        {
            MockDebuggerAttacher
            .Setup(a => a.AttachDebugger(It.IsAny <int>(), It.IsAny <DebuggerEngine>()))
            .Returns(GetAttachDebuggerAction(() => { throw new Exception("my message"); }));

            DoTest(false);

            MockLogger.Verify(l => l.LogError(It.Is <string>(s => s.Contains("my message"))), Times.Once);
        }
Exemplo n.º 7
0
        public void AttachDebugger_AttachingFails_ErrorOutputGenerated()
        {
            MockDebuggerAttacher
            .Setup(a => a.AttachDebugger(It.IsAny <int>(), It.IsAny <DebuggerEngine>()))
            .Returns(GetAttachDebuggerAction(() => false));

            DoTest(false);

            MockLogger.Verify(l => l.LogError(It.Is <string>(s => s.Contains("unknown reasons"))), Times.Once);
        }
Exemplo n.º 8
0
        public void AttachDebugger_AttachingSucceeds_DebugOutputGenerated()
        {
            MockDebuggerAttacher
            .Setup(a => a.AttachDebugger(It.IsAny <int>(), It.IsAny <DebuggerEngine>()))
            .Returns(GetAttachDebuggerAction(() => true));

            DoTest(true);

            MockLogger.Verify(l => l.DebugInfo(It.IsAny <string>()), Times.Exactly(1));
            MockLogger.Verify(l => l.DebugInfo(It.Is <string>(s => s.ToLower().Contains("attached"))));
        }
        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);
            }
        }
Exemplo n.º 10
0
 public void Setup()
 {
     MockDebuggerAttacher.Reset();
     MockLogger.Reset();
 }
 public void Setup()
 {
     MockDebuggerAttacher.Reset();
     MockLogger.Reset();
     _messages.Clear();
 }