public void AddProjectLinkAddsPersistInfoToTargetProject()
        {
            var solution = new MockIVsSolution();
            ProjectLinkTracker tracker = new ProjectLinkTracker(new MockDocumentTracker(), solution, null);
            var sourceHierarchy = new MockVsHierarchy();
            var targetHierarchy = new MockVsHierarchy();

            tracker.AddProjectLink(sourceHierarchy, targetHierarchy);

            Assert.IsTrue(targetHierarchy.GetPropertyProjectValue.Globals.Dictionary.ContainsKey("ProjectLinkReference"));
            Assert.AreEqual(sourceHierarchy.GetPropertyProjectIdGuidValue.ToString(), targetHierarchy.GetPropertyProjectValue.Globals.Dictionary["ProjectLinkReference"]);
            Assert.IsTrue(targetHierarchy.GetPropertyProjectValue.Globals.set_VariablePersistsCalled);
        }
        public void ShouldRegisterInSolutionEvents()
        {
            var vsSolution = new MockIVsSolution();

            ProjectLinkTracker tracker = new ProjectLinkTracker(new MockDocumentTracker(), vsSolution, null);

            Assert.IsTrue(vsSolution.AdviseSolutionEventsCalled);
        }
        public void ShouldRestoreLinksOnServiceInitialization()
        {
            var solution = new MockIVsSolution();
            var sourceHierarchy = new MockVsHierarchy();
            var targetHierarchy = new MockVsHierarchy();
            targetHierarchy.GetPropertyProjectValue.Globals.Dictionary["ProjectLinkReference"] = sourceHierarchy.GetPropertyProjectIdGuidValue.ToString();

            solution.Hierarchies.Add(sourceHierarchy);
            solution.Hierarchies.Add(targetHierarchy);

            var dteSolution = new MockSolution();
            dteSolution.Projects.List.Add(sourceHierarchy.GetPropertyProjectValue);
            dteSolution.Projects.List.Add(targetHierarchy.GetPropertyProjectValue);

            ProjectLinkTracker tracker = new ProjectLinkTracker(new MockDocumentTracker(), solution, new MockLogger(), dteSolution);

            var links = tracker.GetProjectLinks().ToList();
            Assert.AreEqual(1, links.Count);
            Assert.AreEqual(sourceHierarchy.GetPropertyProjectIdGuidValue, links[0].SourceProjectId);
            Assert.AreEqual(targetHierarchy.GetPropertyProjectIdGuidValue, links[0].TargetProjectId);
        }
        public void ShouldRegisterInDocumentTracker()
        {
            var documentTracker = new MockDocumentTracker();

            ProjectLinkTracker tracker = new ProjectLinkTracker(documentTracker, new MockIVsSolution(), null);

            Assert.IsTrue(documentTracker.AdviseTrackProjectDocumentsEventsCalled);
            Assert.AreSame(tracker, documentTracker.AdviseTrackProjectDocumentsEventsArgumentEventSink);
        }