コード例 #1
0
        public async Task InitializeAsync(ReAttachPackage package, ReAttachHistory history, CancellationToken cancellationToken)
        {
            _history = history;
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);


            _ui = (await package.GetServiceAsync(typeof(ReAttachUi))) as ReAttachUi;
            if (_ui == null)
            {
                ReAttachUtils.ShowStartupError("Unable to obtain reference to UI.");
                return;
            }

            var debugger = (await package.GetServiceAsync(typeof(IVsDebugger))) as IVsDebugger;

            if (debugger == null)
            {
                ReAttachUtils.ShowStartupError("Unable to obtain reference to debugger.");
                return;
            }

            if (debugger.AdviseDebugEventCallback(this) != VSConstants.S_OK)
            {
                ReAttachUtils.ShowStartupError("Unable to subscribe on debug events.");
                return;
            }

            if (debugger.AdviseDebuggerEvents(this, out _cookie) != VSConstants.S_OK)
            {
                ReAttachUtils.ShowStartupError("Unable to subscribe on debugger mode changes.");
                return;
            }


            var dte = await package.GetServiceAsync(typeof(EnvDTE.DTE)) as DTE2;

            if (dte == null)
            {
                ReAttachUtils.ShowStartupError("Unable to get obtain reference to automation object model (DTE2).");
                return;
            }

            _dteDebugger = dte.Debugger as Debugger2;
            if (_dteDebugger == null)
            {
                ReAttachUtils.ShowStartupError("Unable to get reference to debugger from automation object.");
                return;
            }

            _engines = GetTransportEngines();
        }
コード例 #2
0
        public void SaveTest()
        {
            var repository = new Mock<IReAttachRepository>(MockBehavior.Strict);
            var history = new ReAttachHistory(repository.Object);
            Assert.IsNotNull(history.Items);

            repository.Setup(r => r.SaveTargets(It.IsAny<ReAttachTargetList>())).Returns(true);
            Assert.IsTrue(history.Save());

            repository.Setup(r => r.SaveTargets(It.IsAny<ReAttachTargetList>())).Returns(false);
            Assert.IsFalse(history.Save());

            repository.Verify(r => r.SaveTargets(It.IsAny<ReAttachTargetList>()), Times.Exactly(2));
        }
コード例 #3
0
        public void SaveTest()
        {
            var repository = new Mock <IReAttachRepository>(MockBehavior.Strict);
            var history    = new ReAttachHistory(repository.Object);

            Assert.IsNotNull(history.Items);

            repository.Setup(r => r.SaveTargets(It.IsAny <ReAttachTargetList>())).Returns(true);
            Assert.IsTrue(history.Save());

            repository.Setup(r => r.SaveTargets(It.IsAny <ReAttachTargetList>())).Returns(false);
            Assert.IsFalse(history.Save());

            repository.Verify(r => r.SaveTargets(It.IsAny <ReAttachTargetList>()), Times.Exactly(2));
        }
コード例 #4
0
        public void LoadTest()
        {
            var repository = new Mock<IReAttachRepository>(MockBehavior.Strict);
            var history = new ReAttachHistory(repository.Object);
            Assert.IsNotNull(history.Items);

            repository.Setup(r => r.LoadTargets()).Returns<ReAttachTargetList>(null);
            Assert.IsFalse(history.Load());
            Assert.IsNotNull(history.Items);

            repository.Setup(r => r.LoadTargets()).Returns(new ReAttachTargetList(ReAttachConstants.ReAttachHistorySize));
            Assert.IsTrue(history.Load());
            Assert.IsNotNull(history.Items);
            Assert.AreEqual(0, history.Items.Count);

            repository.Verify(r => r.LoadTargets(), Times.Exactly(2));
        }
コード例 #5
0
        public void LoadTest()
        {
            var repository = new Mock <IReAttachRepository>(MockBehavior.Strict);
            var history    = new ReAttachHistory(repository.Object);

            Assert.IsNotNull(history.Items);

            repository.Setup(r => r.LoadTargets()).Returns <ReAttachTargetList>(null);
            Assert.IsFalse(history.Load());
            Assert.IsNotNull(history.Items);

            repository.Setup(r => r.LoadTargets()).Returns(new ReAttachTargetList(ReAttachConstants.ReAttachHistorySize));
            Assert.IsTrue(history.Load());
            Assert.IsNotNull(history.Items);
            Assert.AreEqual(0, history.Items.Count);

            repository.Verify(r => r.LoadTargets(), Times.Exactly(2));
        }