public void ShouldSetProjectLinkItemsInView()
        {
            var mockView = new MockLinksEditorView();
            var mockProjectLinkTracker = new MockProjectLinkTracker();
            var sourceHierarchyNode = new MockHierarchyNode {ProjectGuid = Guid.NewGuid(), SolutionRelativeName = "SourceProject"};
            var targetHierarchyNode = new MockHierarchyNode { ProjectGuid = Guid.NewGuid(), SolutionRelativeName = "TargetProject" };
            mockProjectLinkTracker.ProjectLinks = new List<ProjectLink>
                                                      {
                                                          new ProjectLink
                                                              {
                                                                  SourceProjectId = sourceHierarchyNode.ProjectGuid,
                                                                  TargetProjectId = targetHierarchyNode.ProjectGuid
                                                              }
                                                      };
            var mockHierarchyNodeFactory = new MockHierarchyNodeFactory();
            mockHierarchyNodeFactory.HierarchyNodesList.Add(sourceHierarchyNode);
            mockHierarchyNodeFactory.HierarchyNodesList.Add(targetHierarchyNode);

            LinksEditorPresenter presenter = new LinksEditorPresenter(mockView, mockProjectLinkTracker, mockHierarchyNodeFactory);

            Assert.IsTrue(mockProjectLinkTracker.GetProjectLinksCalled);
            Assert.IsTrue(mockView.ProjectLinksCalled);
            Assert.IsNotNull(mockView.ProjectLinks);
            Assert.AreEqual(1, mockView.ProjectLinks.Count);
            Assert.AreEqual("SourceProject", mockView.ProjectLinks[0].SourceProjectName);
            Assert.AreEqual(sourceHierarchyNode.ProjectGuid, mockView.ProjectLinks[0].SourceProjectGuid);
            Assert.AreEqual("TargetProject", mockView.ProjectLinks[0].TargetProjectName);
            Assert.AreEqual(targetHierarchyNode.ProjectGuid, mockView.ProjectLinks[0].TargetProjectGuid);
        }
        public void ShouldSetProjectLinkItemsInView()
        {
            MockLinksEditorView    mockView = new MockLinksEditorView();
            MockProjectLinkTracker mockProjectLinkTracker = new MockProjectLinkTracker();
            MockHierarchyNode      sourceHierarchyNode    = new MockHierarchyNode {
                ProjectGuid = Guid.NewGuid(), SolutionRelativeName = "SourceProject"
            };
            MockHierarchyNode targetHierarchyNode = new MockHierarchyNode {
                ProjectGuid = Guid.NewGuid(), SolutionRelativeName = "TargetProject"
            };

            mockProjectLinkTracker.ProjectLinks = new List <ProjectLink>
            {
                new ProjectLink
                {
                    SourceProjectId = sourceHierarchyNode.ProjectGuid,
                    TargetProjectId = targetHierarchyNode.ProjectGuid
                }
            };
            MockHierarchyNodeFactory mockHierarchyNodeFactory = new MockHierarchyNodeFactory();

            mockHierarchyNodeFactory.HierarchyNodesList.Add(sourceHierarchyNode);
            mockHierarchyNodeFactory.HierarchyNodesList.Add(targetHierarchyNode);

            LinksEditorPresenter presenter = new LinksEditorPresenter(mockView, mockProjectLinkTracker, mockHierarchyNodeFactory);

            Assert.IsTrue(mockProjectLinkTracker.GetProjectLinksCalled);
            Assert.IsTrue(mockView.ProjectLinksCalled);
            Assert.IsNotNull(mockView.ProjectLinks);
            Assert.AreEqual(1, mockView.ProjectLinks.Count);
            Assert.AreEqual("SourceProject", mockView.ProjectLinks[0].SourceProjectName);
            Assert.AreEqual(sourceHierarchyNode.ProjectGuid, mockView.ProjectLinks[0].SourceProjectGuid);
            Assert.AreEqual("TargetProject", mockView.ProjectLinks[0].TargetProjectName);
            Assert.AreEqual(targetHierarchyNode.ProjectGuid, mockView.ProjectLinks[0].TargetProjectGuid);
        }
        public void ShouldUnlinkProjects()
        {
            MockProjectLinkTracker mockProjectLinkTracker = new MockProjectLinkTracker();
            MockHierarchyNode      sourceHierarchyNode    = new MockHierarchyNode {
                ProjectGuid = Guid.NewGuid(), SolutionRelativeName = "SourceProject"
            };
            MockHierarchyNode targetHierarchyNode = new MockHierarchyNode {
                ProjectGuid = Guid.NewGuid(), SolutionRelativeName = "TargetProject"
            };

            mockProjectLinkTracker.ProjectLinks = new List <ProjectLink>
            {
                new ProjectLink
                {
                    SourceProjectId = sourceHierarchyNode.ProjectGuid,
                    TargetProjectId = targetHierarchyNode.ProjectGuid
                }
            };
            MockHierarchyNodeFactory mockHierarchyNodeFactory = new MockHierarchyNodeFactory
            {
                GetSelectedProjectReturnValue = new MockHierarchyNode
                {
                    SolutionRelativeName =
                        targetHierarchyNode.SolutionRelativeName
                }
            };

            mockHierarchyNodeFactory.HierarchyNodesList.Add(sourceHierarchyNode);
            mockHierarchyNodeFactory.HierarchyNodesList.Add(targetHierarchyNode);
            MockLinksEditorView  mockView  = new MockLinksEditorView();
            LinksEditorPresenter presenter = new LinksEditorPresenter(mockView, mockProjectLinkTracker, mockHierarchyNodeFactory);

            mockView.SelectedProjectLinkItems = new Collection <ProjectLinkItem>
            {
                new ProjectLinkItem
                {
                    SourceProjectGuid = sourceHierarchyNode.ProjectGuid,
                    TargetProjectGuid = targetHierarchyNode.ProjectGuid
                }
            };
            mockView.ProjectLinksCalled = false;
            mockProjectLinkTracker.GetProjectLinksCalled = false;

            mockView.FireProjectsUnlinking();

            Assert.IsTrue(mockProjectLinkTracker.UnlinkProjectsCalled);
            Assert.AreEqual(sourceHierarchyNode.ProjectGuid, mockProjectLinkTracker.UnlinkProjectsSourceArgument);
            Assert.AreEqual(targetHierarchyNode.ProjectGuid, mockProjectLinkTracker.UnlinkProjectsTargetArgument);
            Assert.IsTrue(mockProjectLinkTracker.GetProjectLinksCalled);
            Assert.IsTrue(mockView.ProjectLinksCalled);
        }
        public void ShouldSetSelectedProjectOnView()
        {
            MockProjectLinkTracker mockProjectLinkTracker = new MockProjectLinkTracker();
            MockHierarchyNode      sourceHierarchyNode    = new MockHierarchyNode {
                ProjectGuid = Guid.NewGuid(), SolutionRelativeName = "SourceProject"
            };
            MockHierarchyNode targetHierarchyNode = new MockHierarchyNode {
                ProjectGuid = Guid.NewGuid(), SolutionRelativeName = "TargetProject"
            };

            mockProjectLinkTracker.ProjectLinks = new List <ProjectLink>
            {
                new ProjectLink
                {
                    SourceProjectId = sourceHierarchyNode.ProjectGuid,
                    TargetProjectId = targetHierarchyNode.ProjectGuid
                }
            };
            MockHierarchyNodeFactory mockHierarchyNodeFactory = new MockHierarchyNodeFactory
            {
                GetSelectedProjectReturnValue = new MockHierarchyNode
                {
                    SolutionRelativeName =
                        targetHierarchyNode.SolutionRelativeName
                }
            };

            mockHierarchyNodeFactory.HierarchyNodesList.Add(sourceHierarchyNode);
            mockHierarchyNodeFactory.HierarchyNodesList.Add(targetHierarchyNode);
            MockLinksEditorView mockView = new MockLinksEditorView();

            LinksEditorPresenter presenter = new LinksEditorPresenter(mockView, mockProjectLinkTracker, mockHierarchyNodeFactory);

            Assert.IsTrue(mockView.SelectedProjectLinkItemCalled);
            Assert.AreEqual("TargetProject", mockView.SelectedProjectLinkItems[0].TargetProjectName);
        }
        public void ShouldSetSelectedProjectOnView()
        {
            var mockProjectLinkTracker = new MockProjectLinkTracker();
            var sourceHierarchyNode = new MockHierarchyNode() { ProjectGuid = Guid.NewGuid(), SolutionRelativeName = "SourceProject" };
            var targetHierarchyNode = new MockHierarchyNode() { ProjectGuid = Guid.NewGuid(), SolutionRelativeName = "TargetProject" };
            mockProjectLinkTracker.ProjectLinks = new List<ProjectLink>
                                                      {
                                                          new ProjectLink
                                                              {
                                                                  SourceProjectId = sourceHierarchyNode.ProjectGuid,
                                                                  TargetProjectId = targetHierarchyNode.ProjectGuid
                                                              }
                                                      };
            var mockHierarchyNodeFactory = new MockHierarchyNodeFactory();
            mockHierarchyNodeFactory.GetSelectedProjectReturnValue = new MockHierarchyNode()
                                                                         {
                                                                             SolutionRelativeName =
                                                                                 targetHierarchyNode.
                                                                                 SolutionRelativeName
                                                                         };
            mockHierarchyNodeFactory.HierarchyNodesList.Add(sourceHierarchyNode);
            mockHierarchyNodeFactory.HierarchyNodesList.Add(targetHierarchyNode);
            var mockView = new MockLinksEditorView();

            LinksEditorPresenter presenter = new LinksEditorPresenter(mockView, mockProjectLinkTracker, mockHierarchyNodeFactory);

            Assert.IsTrue(mockView.SelectedProjectLinkItemCalled);
            Assert.AreEqual("TargetProject", mockView.SelectedProjectLinkItems[0].TargetProjectName);
        }
        public void ShouldUnlinkProjects()
        {
            var mockProjectLinkTracker = new MockProjectLinkTracker();
            var sourceHierarchyNode = new MockHierarchyNode() { ProjectGuid = Guid.NewGuid(), SolutionRelativeName = "SourceProject" };
            var targetHierarchyNode = new MockHierarchyNode() { ProjectGuid = Guid.NewGuid(), SolutionRelativeName = "TargetProject" };
            mockProjectLinkTracker.ProjectLinks = new List<ProjectLink>
                                                      {
                                                          new ProjectLink
                                                              {
                                                                  SourceProjectId = sourceHierarchyNode.ProjectGuid,
                                                                  TargetProjectId = targetHierarchyNode.ProjectGuid
                                                              }
                                                      };
            var mockHierarchyNodeFactory = new MockHierarchyNodeFactory();
            mockHierarchyNodeFactory.GetSelectedProjectReturnValue = new MockHierarchyNode()
            {
                SolutionRelativeName =
                    targetHierarchyNode.
                    SolutionRelativeName
            };
            mockHierarchyNodeFactory.HierarchyNodesList.Add(sourceHierarchyNode);
            mockHierarchyNodeFactory.HierarchyNodesList.Add(targetHierarchyNode);
            var mockView = new MockLinksEditorView();
            LinksEditorPresenter presenter = new LinksEditorPresenter(mockView, mockProjectLinkTracker, mockHierarchyNodeFactory);
            mockView.SelectedProjectLinkItems = new Collection<ProjectLinkItem>
                                         {
                                             new ProjectLinkItem
                                                 {
                                                     SourceProjectGuid = sourceHierarchyNode.ProjectGuid,
                                                     TargetProjectGuid = targetHierarchyNode.ProjectGuid
                                                 }
                                         };
            mockView.ProjectLinksCalled = false;
            mockProjectLinkTracker.GetProjectLinksCalled = false;

            mockView.FireProjectsUnlinking();

            Assert.IsTrue(mockProjectLinkTracker.UnlinkProjectsCalled);
            Assert.AreEqual(sourceHierarchyNode.ProjectGuid, mockProjectLinkTracker.UnlinkProjectsSourceArgument);
            Assert.AreEqual(targetHierarchyNode.ProjectGuid, mockProjectLinkTracker.UnlinkProjectsTargetArgument);
            Assert.IsTrue(mockProjectLinkTracker.GetProjectLinksCalled);
            Assert.IsTrue(mockView.ProjectLinksCalled);
        }