public void ShouldReturnContainingPathForInputPathAboveRootPath(string path, string expected) { // Given IFileSystem fileSystem = new TestFileSystem(GetFileProvider()); fileSystem.RootPath = "/a/y"; fileSystem.InputPaths.Add("../b"); fileSystem.InputPaths.Add("../x"); // When DirectoryPath inputPathFromFilePath = fileSystem.GetContainingInputPath(new FilePath(path)); DirectoryPath inputPathFromDirectoryPath = fileSystem.GetContainingInputPath(new DirectoryPath(path)); // Then Assert.AreEqual(expected, inputPathFromFilePath?.FullPath); Assert.AreEqual(expected, inputPathFromDirectoryPath?.FullPath); }
public void ThrowsForNullPath() { // Given IFileSystem fileSystem = new TestFileSystem(); // When, Then Should.Throw <ArgumentNullException>(() => fileSystem.GetContainingInputPath(null)); }
public void ShouldReturnContainingPathForRelativeDirectoryPath(string path, string expected) { // Given IFileSystem fileSystem = new TestFileSystem(GetFileProvider()); fileSystem.RootPath = "/a"; fileSystem.InputPaths.Add("b"); fileSystem.InputPaths.Add("y"); // When NormalizedPath inputPath = fileSystem.GetContainingInputPath(new NormalizedPath(path)); // Then inputPath.FullPath.ShouldBe(expected); }
public void ShouldReturnContainingPathWhenOtherInputPathStartsTheSame() { // Given TestFileProvider fileProvider = GetFileProvider(); fileProvider.AddDirectory("yz"); fileProvider.AddDirectory("y"); fileProvider.AddFile("/a/yz/baz.txt"); IFileSystem fileSystem = new TestFileSystem(fileProvider); fileSystem.RootPath = "/a"; fileSystem.InputPaths.Add("yz"); fileSystem.InputPaths.Add("y"); // When DirectoryPath inputPath = fileSystem.GetContainingInputPath(new FilePath("baz.txt")); // Then Assert.AreEqual("/a/yz", inputPath?.FullPath); }
public void ShouldReturnContainingPathWhenOtherInputPathStartsTheSame() { // Given TestFileProvider fileProvider = GetFileProvider(); fileProvider.AddDirectory("yz"); fileProvider.AddDirectory("y"); fileProvider.AddFile("/a/yz/baz.txt"); IFileSystem fileSystem = new TestFileSystem(fileProvider); fileSystem.RootPath = "/a"; fileSystem.InputPaths.Add("yz"); fileSystem.InputPaths.Add("y"); // When NormalizedPath inputPath = fileSystem.GetContainingInputPath(new NormalizedPath("baz.txt")); // Then inputPath.FullPath.ShouldBe("/a/yz"); }