public void Will_Append_Relative_Root_With_Implicit_Working_Directory() { // Given var fixture = new GlobberFixture(); var globber = new Globber(fixture.FileSystem, fixture.Environment); // When var result = globber.Match("Hello/World/Text.txt").ToArray(); // Then Assert.Equal(1, result.Length); Assert.Equal("/Working/Hello/World/Text.txt", result[0].FullPath); }
public void Should_Throw_If_Pattern_Is_Empty() { // Given var fixture = new GlobberFixture(); var globber = new Globber(fixture.FileSystem, fixture.Environment); // When var result = Record.Exception(() => globber.Match(null)); // Then Assert.IsType<ArgumentNullException>(result); Assert.Equal("pattern", ((ArgumentNullException)result).ParamName); }
public void Can_Traverse_Recursivly() { // Given var fixture = new GlobberFixture(); var globber = new Globber(fixture.FileSystem, fixture.Environment); // When var result = globber.Match("/Temp/**/*.txt").ToArray(); // Then Assert.Equal(2, result.Length); Assert.Equal("/Temp/Hello/World/Text.txt", result[0].FullPath); Assert.Equal("/Temp/Goodbye/OtherText.txt", result[1].FullPath); }
public void Will_Fix_Root_If_Drive_Is_Missing_By_Using_The_Drive_From_The_Working_Directory() { // Given var fixture = new GlobberFixture(isUnix: false); fixture.Environment.GetApplicationRoot().Returns("C:/Working/"); var globber = new Globber(fixture.FileSystem, fixture.Environment); // When var result = globber.Match("/Temp/Hello/World/Text.txt").ToArray(); // Then Assert.Equal(1, result.Length); Assert.Equal("C:/Temp/Hello/World/Text.txt", result[0].FullPath); }
public void Should_Ignore_Case_Sensitivity_On_Case_Insensitive_Operative_System(bool isUnix, bool shouldFindFile) { // Given var fixture = new GlobberFixture(isUnix); var globber = new Globber(fixture.FileSystem, fixture.Environment); // When var result = globber.Match("/Temp/**/text.txt").ToArray(); // Then Assert.Equal(shouldFindFile, result.Length == 1); }
public void Should_Throw_If_Unc_Root_Was_Encountered() { // Given var fixture = new GlobberFixture(isUnix: false); var globber = new Globber(fixture.FileSystem, fixture.Environment); // When var result = Record.Exception(() => globber.Match("//Hello/World/Text.txt")); // Then Assert.IsType<NotSupportedException>(result); Assert.Equal("UNC paths are not supported.", result.Message); }