コード例 #1
0
        public void ShouldRenameLinkedFile()
        {
            string oldSourceFile = Path.Combine(@"c:\mockPath1", @"MyOldFilename.cs");
            string newSourceFile = Path.Combine(@"c:\mockPath1", @"MyNewFilename.cs");

            MockProject sourceProject = new MockProject(@"c:\mockPath1\project1.csproj");
            MockProject targetProject = new MockProject();

            sourceProject.ProjectItems.AddProjectItem(new MockProjectItem("MyNewFilename.cs"));
            MockProjectItem targetFile = new MockProjectItem(oldSourceFile, true);

            targetProject.ProjectItems.AddProjectItem(targetFile);

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

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

            syncher.FileRenamedInSource(oldSourceFile, newSourceFile);

            Assert.IsTrue(targetFile.DeleteCalled);
            Assert.IsTrue(targetProject.ProjectItems.AddFromFileCalled);
            Assert.IsNotNull(targetProject.ProjectItems.FirstOrDefault(x => x.Name.EndsWith("MyNewFilename.cs")));
        }