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 ShouldUnlinkProjects()
        {
            var solution = new MockIVsSolution();
            TestableProjectLinkTracker tracker = new TestableProjectLinkTracker(new MockDocumentTracker(), solution);
            var sourceVsHierarchy = new MockVsHierarchy();
            var targetVsHierarchy = new MockVsHierarchy();
            solution.Hierarchies.Add(sourceVsHierarchy);
            solution.Hierarchies.Add(targetVsHierarchy);
            tracker.AddProjectLink(sourceVsHierarchy, targetVsHierarchy);
            targetVsHierarchy.GetPropertyProjectValue.Globals.set_VariablePersistsCalled = false;

            tracker.UnlinkProjects(sourceVsHierarchy.GetPropertyProjectIdGuidValue, targetVsHierarchy.GetPropertyProjectIdGuidValue);

            Assert.AreEqual(0, tracker.GetProjectLinks().Count());
            Assert.IsTrue(targetVsHierarchy.GetPropertyProjectValue.Globals.set_VariablePersistsCalled);
            Assert.IsFalse(targetVsHierarchy.GetPropertyProjectValue.Globals.set_VariablePersistsArgumentValue);
        }
        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 ShouldThrowIfAddingSameLink()
        {
            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, project2VsHierarchy);
            tracker.AddProjectLink(project1VsHierarchy, project2VsHierarchy);
        }
        public void ShouldNotLinkTwiceTheSameTarget()
        {
            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, project3VsHierarchy);
            tracker.AddProjectLink(project2VsHierarchy, project3VsHierarchy);
        }
        public void ShouldGetLinkedProject()
        {
            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, project2VsHierarchy);

            var projectLinks = tracker.GetProjectLinks();

            Assert.AreEqual(1, projectLinks.Count());
            var projectLink = projectLinks.ElementAt(0);
            Assert.AreEqual(project1VsHierarchy.GetPropertyProjectIdGuidValue, projectLink.SourceProjectId);
            Assert.AreEqual(project2VsHierarchy.GetPropertyProjectIdGuidValue, projectLink.TargetProjectId);
        }