public void AbsoluteToRelativePaths() { PathRef pathRef = new PathRef("DirA/DirB"); pathRef.JoinWith("../../../DirC"); Assert.That(pathRef.PosixPath, Is.EqualTo(@"../DirC")); }
public void When_EmptyJoiningWithNull() { PathRef pathRef = new PathRef(); Assert.That(() => { pathRef.JoinWith(null); }, Throws.Nothing); Assert.That(pathRef.ToString(), Is.EqualTo("")); }
public void When_EmptyJoiningWithRelativePath(string[] toJoin, string expectedOutput) { PathRef pathRef = new PathRef(); Assert.That(() => { pathRef.JoinWith(toJoin); }, Throws.Nothing); Assert.That(pathRef.ToString(), Is.EqualTo(expectedOutput)); }
public void NavigationJoin() { PathRef pathRef = new PathRef("DirA/DirB"); pathRef.JoinWith("DirE/../DirF"); //Relative paths are also allowed Assert.That(pathRef.PosixPath, Is.EqualTo(@"DirA/DirB/DirF")); }
public void When_Combine5(string path1, string path2, string path3, string path4, string path5) { //Take note PathRef.Combine does never initialize the PathRef empty, so we should not expect it to either var expectedPathRef = new PathRef(path1); expectedPathRef.JoinWith(path2, path3, path4, path5); Assert.That(PathRef.Combine(path1, path2, path3, path4, path5), Is.EqualTo(expectedPathRef)); }
public void When_JoiningRootedWithRootedPath(string original, string[] toJoin, string expectedOutput) { PathRef pathRef = new PathRef(original); Assert.That(() => { pathRef.JoinWith(toJoin); }, Throws.Nothing); Assert.That(pathRef.IsRooted, Is.True); Assert.That(pathRef.ToString(), Is.EqualTo(expectedOutput)); }
public void When_JoiningWithNullArray(string original) { PathRef pathRef = new PathRef(original); string expectedOutput = pathRef.ToString(); Assert.That(() => { pathRef.JoinWith(new string[] { null, null, null }); }, Throws.Nothing); Assert.That(pathRef.ToString(), Is.EqualTo(expectedOutput)); }
public void Rooting() { PathRef pathRef = new PathRef("C:/DirA"); Assert.That(pathRef.IsRooted, Is.True); pathRef.JoinWith("../../../.."); Assert.That(pathRef.PosixPath, Is.EqualTo(@"C:")); pathRef.Clear(); Assert.That(pathRef.IsRooted, Is.False); }