public void ShouldNotRemoveFileIfTargetFileIsNotALink()
        {
            MockLogger      mockLogger    = new MockLogger();
            MockProject     sourceProject = new MockProject(@"c:\mockPath1\project1.csproj");
            MockProject     targetProject = new MockProject();
            MockProjectItem targetFile    = new MockProjectItem("MyClass.cs")
            {
                Kind = Constants.vsProjectItemKindPhysicalFile
            };

            targetProject.ProjectItems.AddProjectItem(targetFile);

            string sourceFile = Path.Combine(@"c:\mockPath1", @"MyClass.cs");
            ProjectItemsSynchronizer syncher = new ProjectItemsSynchronizer(sourceProject, targetProject, mockLogger, null, new MockProjectItemsFilter());

            Assert.AreEqual(1, targetProject.ProjectItems.Count);

            syncher.FileRemovedFromSource(sourceFile);

            Assert.IsFalse(targetFile.DeleteCalled);
            Assert.AreEqual(1, mockLogger.MessageLog.Count);
            StringAssert.Contains(mockLogger.MessageLog[0], "not linked");
            StringAssert.Contains(mockLogger.MessageLog[0], @"MyClass.cs");
            StringAssert.Contains(mockLogger.MessageLog[0], targetProject.Name);
        }
        public void ShouldLogMessageIfFileDoesNotExistInTargetProject()
        {
            MockLogger  mockLogger    = new MockLogger();
            MockProject sourceProject = new MockProject(@"c:\mockPath1\project1.csproj");
            MockProject targetProject = new MockProject();

            string sourceFile = Path.Combine(@"c:\mockPath1", @"MyClass.cs");
            ProjectItemsSynchronizer syncher = new ProjectItemsSynchronizer(sourceProject, targetProject, mockLogger, null, new MockProjectItemsFilter());

            syncher.FileRemovedFromSource(sourceFile);

            Assert.AreEqual(1, mockLogger.MessageLog.Count);
            StringAssert.Contains(mockLogger.MessageLog[0], "not linked");
            StringAssert.Contains(mockLogger.MessageLog[0], @"MyClass.cs");
            StringAssert.Contains(mockLogger.MessageLog[0], targetProject.Name);
        }
        public void ShouldRemoveLinkedFileInSubFolderWhenDeletingFromSource()
        {
            string          sourceFile    = @"c:\mockPath1\SubFolder\MyClass.cs";
            MockProject     sourceProject = new MockProject(@"c:\mockPath1\project1.csproj");
            MockProject     targetProject = new MockProject();
            MockProjectItem subFolder     = new MockProjectItem("SubFolder")
            {
                Kind = Constants.vsProjectItemKindPhysicalFolder
            };
            MockProjectItem targetFile = new MockProjectItem(sourceFile, true);

            subFolder.ProjectItems.AddProjectItem(targetFile);
            targetProject.ProjectItems.AddProjectItem(subFolder);

            ProjectItemsSynchronizer syncher = new ProjectItemsSynchronizer(sourceProject, targetProject, new MockLogger(), null, new MockProjectItemsFilter());

            syncher.FileRemovedFromSource(sourceFile);

            Assert.IsTrue(targetFile.DeleteCalled);
        }
        public void ShouldRemoveLinkedFileEvenWhenSourceIsALink()
        {
            string          sourceFile    = @"c:\alternativeExternalPath\file.txt";
            MockLogger      mockLogger    = new MockLogger();
            MockProject     sourceProject = new MockProject(@"c:\mockPath1\project1.csproj");
            MockProject     targetProject = new MockProject();
            MockProjectItem targetFile    = new MockProjectItem(sourceFile, true);

            targetProject.ProjectItems.AddProjectItem(targetFile);

            ProjectItemsSynchronizer syncher = new ProjectItemsSynchronizer(sourceProject, targetProject, mockLogger, null, new MockProjectItemsFilter());

            Assert.AreEqual(1, targetProject.ProjectItems.Count);

            syncher.FileRemovedFromSource(sourceFile);

            Assert.IsTrue(targetFile.DeleteCalled);
            Assert.AreEqual(1, mockLogger.MessageLog.Count);
            StringAssert.Contains(mockLogger.MessageLog[0], "removed");
            StringAssert.Contains(mockLogger.MessageLog[0], @"file.txt");
            StringAssert.Contains(mockLogger.MessageLog[0], targetProject.Name);
        }