public ProjectViewModel( ProjectFile projectFile ) { _projectFile = projectFile; _allReferences = _projectFile.References() .Where( r => r.HasHintPath ) .Select( r => new ReferenceViewModel( r ) ) .ToList(); References = _allReferences; }
private static void AssertReplaceDefinedHintPaths( ProjectFile projectFile, ProjectFile processedProjectFile ) { foreach( var expectedReference in projectFile.References() ) { var reference = processedProjectFile.References() .Single( i => i.Include == expectedReference.Include ); Assert.That( reference.HintPath, Is.EqualTo( expectedReference.NewHintPath ) ); } }
public void BeforeEachTest() { Project = TestObjectFactory.ProjectFile(); TestLog = new TestLog(); CheckOutService = new CheckoutServiceStub( TestLog ); FileCopyService = new FileCopyServiceStub { ThrowException = false }; ReferenceHintPathService = new ReferenceHintPathServiceStub( TestLog ); ReferenceMover = new ReferenceMover.Core.ReferenceMover( CheckOutService, FileCopyService, ReferenceHintPathService ); }
private List<Reference> GetReferences( ProjectFile project ) { return ReferenceFilter.Empty() ? project.References() .Where( r => r.HasHintPath ) .ToList() : project.References() .Where( r => ReferenceFilter.Contains( r.Id ) ) .Where( r => r.HasHintPath ) .ToList(); }
public void Visit( ProjectFile project ) { var projectDirectory = Path.GetFileNameWithoutExtension( project.FilePath ); var references = GetReferences( project ); foreach( var reference in references ) { var fileName = Path.GetFileName( reference.HintPath ); reference.NewHintPath = Path.Combine( RootDirectory, projectDirectory, fileName ); } }
public void Copy_Referenced_Files_With_Absolute_Path_To_NewHintPath_Destination() { var project = new ProjectFile { FilePath = @"C:\PathToProject\Project.csproj" }; project.AddReference( "assembly1", @"\\RemoteAbsolutePath\assembly1.dll", @"D:\NewDir\assembly1.dll" ); project.AddReference( "assembly2", @"C:\LocalAbsolutePath\assembly2.dll", @"D:\NewDir\assembly2.dll" ); // WHEN ReferenceMover.MoveReferences( new[] { project } ); // THEN var expectedCopiedFiles = project.References() .Where( r => r.CanBeMoved() ) .Select( r => new Tuple<string, string>( r.HintPath, r.NewHintPath ) ) .ToList(); Assert.That( FileCopyService.CopiedFiles, Is.EquivalentTo( expectedCopiedFiles ) ); }
public void Copy_Referenced_Files_With_Relative_Path_To_NewHintPath_Destination() { var project = new ProjectFile { FilePath = @"C:\PathToProject\Project.csproj" }; project.AddReference( "assembly1", @"..\RelativePath\assembly1.dll", @"D:\NewDir\assembly1.dll" ); project.AddReference( "assembly2", @"assembly2.dll", @"D:\NewDir\assembly2.dll" ); // WHEN ReferenceMover.MoveReferences( new[] { project } ); // THEN var projectDir = Path.GetDirectoryName( project.FilePath ); var expectedCopiedFiles = project.References() .Where( r => r.CanBeMoved() ) .Select( r => new Tuple<string, string>( Path.Combine( projectDir, r.HintPath ), r.NewHintPath ) ) .ToList(); Assert.That( FileCopyService.CopiedFiles, Is.EquivalentTo( expectedCopiedFiles ) ); }