public void Resituate_OneMatchingChunk_Normal() { string filePathA = @"C:\Users\Alice\Documents\Codes\OpenSource\Project\README.md"; string filePathB = @"https://filestore.cloud.example/Alice/"; var actual = PathMatcher.Resituate(filePathA, filePathB); var expected = @"https://filestore.cloud.example/Alice/Documents/Codes/OpenSource/Project/README.md"; Assert.AreEqual(expected, actual); }
public void Resituate_NoMatchesJustPutSourceFileInDestDir() { string filePathA = @"C:\Users\Alice\Documents\Codes\OpenSource\Project\README.md"; string filePathB = @"https://filestore.cloud.example/#!/AJones/Files/"; var actual = PathMatcher.Resituate(filePathA, filePathB); var expected = @"https://filestore.cloud.example/#!/AJones/Files/README.md"; Assert.AreEqual(expected, actual); }
public void Resituate_UseLastOfMultipleMatches() { string filePathA = @"C:\Users\Alice\Documents\Codes\OpenSource\Project\README.md"; string filePathB = @"https://filestore.cloud.example/#!/Alice/OpenSource/"; var actual = PathMatcher.Resituate(filePathA, filePathB); var expected = @"https://filestore.cloud.example/#!/Alice/OpenSource/Project/README.md"; Assert.AreEqual(expected, actual); }
public void Resituate_MatchesInSkewedOrder() { string filePathA = @"C:\Users\Alice\Documents\OpenSource\Codes\Project\README.md"; string filePathB = @"https://filestore.cloud.example/Alice/Codes/OpenSource/"; //The correct behaviour is, in fact, to match on the 'OpenSource' chunk // and then copy the directory tree after that from the source var expected = @"https://filestore.cloud.example/Alice/Codes/OpenSource/Codes/Project/README.md"; var actual = PathMatcher.Resituate(filePathA, filePathB); Assert.AreEqual(expected, actual); }
public void ExampleUsageForReadme() { string myPath = @"C:\Users\Coder\Documents\Code\Project\File.cs"; var pathInfo = new PathInfo(myPath); pathInfo.ConformSeparatorTo('/'); //Remove the filename (strip it back to directory only) pathInfo.SetFileName(""); pathInfo.AddChunks(true, "src", "Controllers"); pathInfo.SetFileName("FileNameController.cs"); Assert.AreEqual(@"C:\Users\Coder\Documents\Code\Project\src\Controllers\FileNameController.cs", pathInfo.FilePath); string remotePath = "https://files.example/Coder/Documents/"; string newPath = PathMatcher.Resituate(pathInfo.FilePath, remotePath); string expected = "https://files.example/Coder/Documents/Code/Project/src/Controllers/FileNameController.cs"; Assert.AreEqual(expected, newPath); }