示例#1
0
            public void AbsoluteToRelativePaths()
            {
                PathRef pathRef = new PathRef("DirA/DirB");

                pathRef.JoinWith("../../../DirC");
                Assert.That(pathRef.PosixPath, Is.EqualTo(@"../DirC"));
            }
示例#2
0
            public void When_EmptyJoiningWithNull()
            {
                PathRef pathRef = new PathRef();

                Assert.That(() => { pathRef.JoinWith(null); }, Throws.Nothing);
                Assert.That(pathRef.ToString(), Is.EqualTo(""));
            }
示例#3
0
            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));
            }
示例#4
0
            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"));
            }
示例#5
0
            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));
            }
示例#6
0
            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));
            }
示例#7
0
            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));
            }
示例#8
0
            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);
            }