public void ShouldIncludeSubDirectoryInTargetWhenItsPresentInFileSystem()
        {
            MockIVsSolution mockSolution          = new MockIVsSolution();
            MockVsHierarchy mockTargetVsHierarchy = new MockVsHierarchy();
            MockProject     sourceProject         = new MockProject(@"c:\mockPath1\project1.csproj");
            MockProject     targetProject         = new MockProject(@"c:\mockPath2\project1.csproj");

            mockTargetVsHierarchy.GetPropertyProjectValue = targetProject;
            mockSolution.Hierarchies.Add(mockTargetVsHierarchy);

            targetProject.ProjectItems.AddFolder("Folder1", Constants.vsProjectItemKindPhysicalFolder);
            MockProjectItem folder1 = targetProject.ProjectItems.Item(0) as MockProjectItem;

            folder1.ProjectItems.ThrowOnAddFolder = true;

            MockHierarchyHelper      mockHierarchyHelper = new MockHierarchyHelper();
            MockLogger               mockLogger          = new MockLogger();
            ProjectItemsSynchronizer syncher             = new ProjectItemsSynchronizer(sourceProject, targetProject, mockLogger, mockSolution, mockHierarchyHelper,
                                                                                        new MockProjectItemsFilter());
            string directoryToAdd = @"c:\mockPath1\Folder1\Folder2\";

            syncher.DirectoryAddedToSource(directoryToAdd);

            Assert.IsTrue(mockTargetVsHierarchy.AddItemCalled);
            Assert.AreEqual(VSConstants.VSITEMID_ROOT, mockTargetVsHierarchy.AddItemArgumentItemidLoc);
            Assert.AreEqual(string.Empty, mockTargetVsHierarchy.AddItemArgumentItemName);
            Assert.AreEqual <uint>(1, mockTargetVsHierarchy.AddItemArgumentFilesToOpen);
            Assert.AreEqual(@"c:\mockPath2\Folder1\Folder2", mockTargetVsHierarchy.AddItemArgumentArrayFilesToOpen[0]);
            Assert.AreEqual(1, mockLogger.MessageLog.Count);
            StringAssert.Contains(mockLogger.MessageLog[0], "already exists");
            StringAssert.Contains(mockLogger.MessageLog[0], "included");
            StringAssert.Contains(mockLogger.MessageLog[0], @"Folder2");
            StringAssert.Contains(mockLogger.MessageLog[0], targetProject.Name);
        }
        public void ShouldIncludeDirectoryInTargetWhenItsPresentInFileSystem()
        {
            MockIVsSolution mockSolution          = new MockIVsSolution();
            MockVsHierarchy mockTargetVsHierarchy = new MockVsHierarchy();
            MockProject     sourceProject         = new MockProject(@"c:\mockPath1\project1.csproj");
            MockProject     targetProject         = new MockProject(@"c:\mockPath2\project1.csproj");

            mockTargetVsHierarchy.GetPropertyProjectValue = targetProject;
            mockSolution.Hierarchies.Add(mockTargetVsHierarchy);
            MockHierarchyHelper      mockHierarchyHelper = new MockHierarchyHelper();
            MockLogger               mockLogger          = new MockLogger();
            ProjectItemsSynchronizer syncher             = new ProjectItemsSynchronizer(sourceProject, targetProject, mockLogger, mockSolution, mockHierarchyHelper,
                                                                                        new MockProjectItemsFilter());
            string directoryToAdd = @"c:\mockPath1\MyFolder\";

            targetProject.ProjectItems.ThrowOnAddFolder = true;

            syncher.DirectoryAddedToSource(directoryToAdd);

            Assert.IsTrue(mockTargetVsHierarchy.AddItemCalled);
            Assert.AreEqual(VSConstants.VSITEMID_ROOT, mockTargetVsHierarchy.AddItemArgumentItemidLoc);
            Assert.AreEqual(string.Empty, mockTargetVsHierarchy.AddItemArgumentItemName);
            Assert.AreEqual <uint>(1, mockTargetVsHierarchy.AddItemArgumentFilesToOpen);
            Assert.AreEqual(@"c:\mockPath2\MyFolder", mockTargetVsHierarchy.AddItemArgumentArrayFilesToOpen[0]);
        }
        public void ShouldThrowIfComExceptionErrorCodeIsNotTheExpected()
        {
            MockIVsSolution mockSolution          = new MockIVsSolution();
            MockVsHierarchy mockTargetVsHierarchy = new MockVsHierarchy();

            mockSolution.Hierarchies.Add(mockTargetVsHierarchy);
            MockProject sourceProject = new MockProject(@"c:\mockPath1\project1.csproj");
            MockProject targetProject = new MockProject(@"c:\mockPath2\project1.csproj");

            targetProject.ProjectItems.ThrowOnAddFolder = true;
            targetProject.ProjectItems.ErrorCode        = VSConstants.S_FALSE;

            MockHierarchyHelper      mockHierarchyHelper = new MockHierarchyHelper();
            MockLogger               mockLogger          = new MockLogger();
            ProjectItemsSynchronizer syncher             = new ProjectItemsSynchronizer(sourceProject, targetProject, mockLogger, mockSolution, mockHierarchyHelper,
                                                                                        new MockProjectItemsFilter());
            string directoryToAdd = @"c:\mockPath1\MyFolder\";

            syncher.DirectoryAddedToSource(directoryToAdd);
        }
        public void ShouldThrowIfCOMExceptionErrorCodeIsNotTheExpected()
        {
            var mockSolution = new MockIVsSolution();
            var mockTargetVsHierarchy = new MockVsHierarchy();
            mockSolution.Hierarchies.Add(mockTargetVsHierarchy);
            var sourceProject = new MockProject(@"c:\mockPath1\project1.csproj");
            var targetProject = new MockProject(@"c:\mockPath2\project1.csproj");
            targetProject.ProjectItems.ThrowOnAddFolder = true;
            targetProject.ProjectItems.ErrorCode = VSConstants.S_FALSE;

            var mockHierarchyHelper = new MockHierarchyHelper();
            var mockLogger = new MockLogger();
            var syncher = new ProjectItemsSynchronizer(sourceProject, targetProject, mockLogger, mockSolution, mockHierarchyHelper, new MockProjectItemsFilter());
            string directoryToAdd = @"c:\mockPath1\MyFolder\";

            syncher.DirectoryAddedToSource(directoryToAdd);
        }
        public void ShouldIncludeSubDirectoryInTargetWhenItsPresentInFileSystem()
        {
            var mockSolution = new MockIVsSolution();
            var mockTargetVsHierarchy = new MockVsHierarchy();
            var sourceProject = new MockProject(@"c:\mockPath1\project1.csproj");
            var targetProject = new MockProject(@"c:\mockPath2\project1.csproj");
            mockTargetVsHierarchy.GetPropertyProjectValue = targetProject;
            mockSolution.Hierarchies.Add(mockTargetVsHierarchy);

            targetProject.ProjectItems.AddFolder("Folder1", Constants.vsProjectItemKindPhysicalFolder);
            MockProjectItem folder1 = targetProject.ProjectItems.Item(0) as MockProjectItem;
            folder1.ProjectItems.ThrowOnAddFolder = true;

            var mockHierarchyHelper = new MockHierarchyHelper();
            var mockLogger = new MockLogger();
            var syncher = new ProjectItemsSynchronizer(sourceProject, targetProject, mockLogger, mockSolution, mockHierarchyHelper, new MockProjectItemsFilter());
            string directoryToAdd = @"c:\mockPath1\Folder1\Folder2\";

            syncher.DirectoryAddedToSource(directoryToAdd);

            Assert.IsTrue(mockTargetVsHierarchy.AddItemCalled);
            Assert.AreEqual(VSConstants.VSITEMID_ROOT, mockTargetVsHierarchy.AddItemArgumentItemidLoc);
            Assert.AreEqual(string.Empty, mockTargetVsHierarchy.AddItemArgumentItemName);
            Assert.AreEqual<uint>(1, mockTargetVsHierarchy.AddItemArgumentFilesToOpen);
            Assert.AreEqual(@"c:\mockPath2\Folder1\Folder2", mockTargetVsHierarchy.AddItemArgumentArrayFilesToOpen[0]);
            Assert.AreEqual(1, mockLogger.MessageLog.Count);
            StringAssert.Contains(mockLogger.MessageLog[0], "already exists");
            StringAssert.Contains(mockLogger.MessageLog[0], "included");
            StringAssert.Contains(mockLogger.MessageLog[0], @"Folder2");
            StringAssert.Contains(mockLogger.MessageLog[0], targetProject.Name);
        }
        public void ShouldIncludeDirectoryInTargetWhenItsPresentInFileSystem()
        {
            var mockSolution = new MockIVsSolution();
            var mockTargetVsHierarchy = new MockVsHierarchy();
            var sourceProject = new MockProject(@"c:\mockPath1\project1.csproj");
            var targetProject = new MockProject(@"c:\mockPath2\project1.csproj");
            mockTargetVsHierarchy.GetPropertyProjectValue = targetProject;
            mockSolution.Hierarchies.Add(mockTargetVsHierarchy);
            var mockHierarchyHelper = new MockHierarchyHelper();
            var mockLogger = new MockLogger();
            var syncher = new ProjectItemsSynchronizer(sourceProject, targetProject, mockLogger, mockSolution, mockHierarchyHelper, new MockProjectItemsFilter());
            string directoryToAdd = @"c:\mockPath1\MyFolder\";
            targetProject.ProjectItems.ThrowOnAddFolder = true;

            syncher.DirectoryAddedToSource(directoryToAdd);

            Assert.IsTrue(mockTargetVsHierarchy.AddItemCalled);
            Assert.AreEqual(VSConstants.VSITEMID_ROOT, mockTargetVsHierarchy.AddItemArgumentItemidLoc);
            Assert.AreEqual(string.Empty, mockTargetVsHierarchy.AddItemArgumentItemName);
            Assert.AreEqual<uint>(1, mockTargetVsHierarchy.AddItemArgumentFilesToOpen);
            Assert.AreEqual(@"c:\mockPath2\MyFolder", mockTargetVsHierarchy.AddItemArgumentArrayFilesToOpen[0]);
        }