public void ShouldAddNewItemsToSync()
        {
            var solution = new MockIVsSolution();
            TestableProjectLinkTracker tracker = new TestableProjectLinkTracker(new MockDocumentTracker(), solution);
            var project1VsHierarchy = new MockVsHierarchy();
            var project2VsHierarchy = new MockVsHierarchy();
            solution.Hierarchies.Add(project1VsHierarchy);
            solution.Hierarchies.Add(project2VsHierarchy);

            tracker.AddProjectLink(project1VsHierarchy.GetPropertyProjectIdGuidValue, project2VsHierarchy.GetPropertyProjectIdGuidValue);

            Assert.IsTrue(tracker.ProjectsAreLinked(project1VsHierarchy, project2VsHierarchy));
            Assert.IsFalse(tracker.ProjectsAreLinked(project2VsHierarchy, project1VsHierarchy));
        }
        public void ShouldCreateSyncherWhenLoadingLinkedSourceProjectAfterTargetProject()
        {
            var solution = new MockIVsSolution();
            TestableProjectLinkTracker tracker = new TestableProjectLinkTracker(new MockDocumentTracker(), solution);
            var sourceHierarchy = new MockVsHierarchy();
            var targetHierarchy = new MockVsHierarchy();
            targetHierarchy.GetPropertyProjectValue.Globals.Dictionary["ProjectLinkReference"] = sourceHierarchy.GetPropertyProjectIdGuidValue.ToString();

            tracker.OnAfterOpenProject(targetHierarchy, 0);

            Assert.IsFalse(tracker.ProjectsAreLinked(sourceHierarchy, targetHierarchy));

            solution.Hierarchies.Add(sourceHierarchy);
            tracker.OnAfterOpenProject(sourceHierarchy, 0);

            Assert.IsTrue(tracker.ProjectsAreLinked(sourceHierarchy, targetHierarchy));
        }
        public void ShouldTrackMultipleProjects()
        {
            var solution = new MockIVsSolution();
            TestableProjectLinkTracker tracker = new TestableProjectLinkTracker(new MockDocumentTracker(), solution);
            var project1VsHierarchy = new MockVsHierarchy();
            var project2VsHierarchy = new MockVsHierarchy();
            var project3VsHierarchy = new MockVsHierarchy();
            solution.Hierarchies.Add(project1VsHierarchy);
            solution.Hierarchies.Add(project2VsHierarchy);
            solution.Hierarchies.Add(project3VsHierarchy);

            tracker.AddProjectLink(project1VsHierarchy, project2VsHierarchy);
            tracker.AddProjectLink(project1VsHierarchy, project3VsHierarchy);

            Assert.IsTrue(tracker.ProjectsAreLinked(project1VsHierarchy, project2VsHierarchy));
            Assert.IsTrue(tracker.ProjectsAreLinked(project1VsHierarchy, project3VsHierarchy));
        }
        public void ShouldNotRestartTrackingIfSourceAndTargetProjectsAreClosedAndSourceGetsReopened()
        {
            var solution = new MockIVsSolution();
            TestableProjectLinkTracker tracker = new TestableProjectLinkTracker(new MockDocumentTracker(), solution);
            var sourceHierarchy = new MockVsHierarchy();
            var targetHierarchy = new MockVsHierarchy();
            targetHierarchy.GetPropertyProjectValue.Globals.Dictionary["ProjectLinkReference"] = sourceHierarchy.GetPropertyProjectIdGuidValue.ToString();
            solution.Hierarchies.Add(sourceHierarchy);
            tracker.OnAfterOpenProject(sourceHierarchy, 0);
            tracker.OnAfterOpenProject(targetHierarchy, 0);

            tracker.OnBeforeCloseProject(sourceHierarchy, 0);
            tracker.OnBeforeCloseProject(targetHierarchy, 0);
            tracker.OnAfterOpenProject(sourceHierarchy, 0);

            Assert.IsFalse(tracker.ProjectsAreLinked(sourceHierarchy, targetHierarchy));
        }