Esempio n. 1
0
            public void When_FromStringToPath(string input)
            {
                PathRef castedPathRef      = input;
                PathRef constructedPathRef = new PathRef(input);

                Assert.That(castedPathRef.ToString(), Is.EqualTo(constructedPathRef.ToString()));
            }
Esempio n. 2
0
            public void When_FromPathToString(string input)
            {
                PathRef pathRef = new PathRef(input);
                string  casted  = pathRef;

                Assert.That(casted, Is.EqualTo(pathRef.ToString()));
            }
Esempio n. 3
0
            public void NormalizingRooted()
            {
                PathRef pathRef = new PathRef(@"C:\DirA\DirB");

                Assert.That(pathRef.WindowsPath, Is.EqualTo(@"C:\DirA\DirB"));
                Assert.That(pathRef.PosixPath, Is.EqualTo(@"C:/DirA/DirB"));
            }
Esempio n. 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"));
            }
Esempio n. 5
0
            public void When_UsingPointToParent(string input, string expectedOutput)
            {
                PathRef pathRef = new PathRef(input);

                Assert.That(() => { pathRef.PointToParent(); }, Throws.Nothing);
                Assert.That(pathRef.ToString(), Is.EqualTo(expectedOutput));
            }
Esempio n. 6
0
            public void AbsoluteToRelativePaths()
            {
                PathRef pathRef = new PathRef("DirA/DirB");

                pathRef.JoinWith("../../../DirC");
                Assert.That(pathRef.PosixPath, Is.EqualTo(@"../DirC"));
            }
Esempio n. 7
0
            public void When_EmptyJoiningWithNull()
            {
                PathRef pathRef = new PathRef();

                Assert.That(() => { pathRef.JoinWith(null); }, Throws.Nothing);
                Assert.That(pathRef.ToString(), Is.EqualTo(""));
            }
Esempio n. 8
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));
            }
Esempio n. 9
0
            public void When_ComparingToEmptyPathRef(string inputA)
            {
                PathRef pathRefA     = new PathRef(inputA);
                PathRef emptyPathRef = new PathRef();

                Assert.That(pathRefA.Equals(emptyPathRef), Is.False);
            }
Esempio n. 10
0
            public void Normalizing()
            {
                PathRef pathRef = new PathRef("../DirA/DirB");

                Assert.That(pathRef.WindowsPath, Is.EqualTo(@"..\DirA\DirB"));
                Assert.That(pathRef.PosixPath, Is.EqualTo(@"../DirA/DirB"));
            }
Esempio n. 11
0
            public void When_ComparingEmptyPathRefs()
            {
                PathRef pathRefA = new PathRef();
                PathRef pathRefB = new PathRef();

                Assert.That(pathRefA.Equals(pathRefB), Is.True);
            }
Esempio n. 12
0
            public void When_UsingPointToChildWithValidArguments(string input, string childName, string expectedOutput)
            {
                PathRef pathRef = new PathRef(input);

                Assert.That(() => { pathRef.PointToChild(childName); }, Throws.Nothing);
                Assert.That(pathRef.ToString(), Is.EqualTo(expectedOutput));
            }
Esempio n. 13
0
        public void When_CreatingWithNull()
        {
            PathRef pathRef = new PathRef(null);

            Assert.That(pathRef.IsNull, Is.True);
            Assert.That(pathRef.ToString(), Is.Null);
        }
Esempio n. 14
0
            public void Clearing()
            {
                PathRef pathRef = new PathRef("DirA/DirB");

                pathRef.Clear();
                Assert.That(pathRef.PosixPath, Is.EqualTo(""));
            }
Esempio n. 15
0
            public void When_ComparingToInequalPathRef(string inputA, string inputB)
            {
                PathRef pathRefA = new PathRef(inputA);
                PathRef pathRefB = new PathRef(inputB);

                Assert.That(pathRefA.Equals(pathRefB), Is.False);
            }
Esempio n. 16
0
            public void WhenBreakoutRelativePath(string input, char directorySeparator, string expected)
            {
                PathRef pathRef    = new PathRef(input);
                string  normalized = pathRef.NormalizePath(directorySeparator);

                Assert.That(normalized, Is.EqualTo(expected));
            }
Esempio n. 17
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));
            }
Esempio n. 18
0
            public void RelativePaths()
            {
                PathRef pathRef = new PathRef("../DirB");

                Assert.That(pathRef.IsRelative, Is.True);
                Assert.That(pathRef.IsAbsolute, Is.False);
                Assert.That(pathRef.PosixPath, Is.EqualTo(@"../DirB"));
            }
Esempio n. 19
0
        public void When_CreatingEmpty()
        {
            PathRef pathRef = new PathRef();

            Assert.That(pathRef.IsNull, Is.False);
            Assert.That(pathRef.IsEmpty, Is.True);
            Assert.That(pathRef.ToString(), Is.EqualTo(""));
        }
Esempio n. 20
0
            public void When_RootedPathIsGiven(string str)
            {
                PathRef pathRef = new PathRef(str);

                Assert.That(pathRef.IsAbsolute, Is.True);
                Assert.That(pathRef.IsRelative, Is.False);
                Assert.That(pathRef.IsRooted, Is.True);
            }
Esempio n. 21
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));
            }
Esempio n. 22
0
            public void When_UsingClearOnEmptyPath()
            {
                PathRef pathRef = new PathRef();

                Assert.That(() => { pathRef.Clear(); }, Throws.Nothing);
                Assert.That(pathRef.IsEmpty, Is.True);
                Assert.That(pathRef.ToString(), Is.EqualTo(""));
            }
Esempio n. 23
0
            public void When_IsNull()
            {
                PathRef pathRef = new PathRef(null);

                Assert.That(pathRef.IsAbsolute, Is.False);
                Assert.That(pathRef.IsRelative, Is.False);
                Assert.That(pathRef.IsRooted, Is.False);
            }
Esempio n. 24
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));
            }
Esempio n. 25
0
            public void When_UsingClearOnAbsolutePath(string input)
            {
                PathRef pathRef = new PathRef(input);

                Assert.That(() => { pathRef.Clear(); }, Throws.Nothing);
                Assert.That(pathRef.IsAbsolute, Is.True);
                Assert.That(pathRef.IsEmpty, Is.False);
                Assert.That(pathRef.ToString(), Is.EqualTo(@"\"));
            }
Esempio n. 26
0
            public void Navigation()
            {
                PathRef pathRef = new PathRef("DirA/DirB");

                pathRef.PointToParent();
                Assert.That(pathRef.PosixPath, Is.EqualTo(@"DirA"));
                pathRef.PointToChild("DirC");
                Assert.That(pathRef.PosixPath, Is.EqualTo(@"DirA/DirC"));
            }
Esempio n. 27
0
            public void When_UsingClearOnRelativePath(string input)
            {
                PathRef pathRef = new PathRef(input);

                Assert.That(() => { pathRef.Clear(); }, Throws.Nothing);
                Assert.That(pathRef.IsRelative, Is.True);
                Assert.That(pathRef.IsEmpty, Is.True);
                Assert.That(pathRef.ToString(), Is.EqualTo(""));
            }
Esempio n. 28
0
            public void When_UsingClearOnNullPath()
            {
                PathRef pathRef = new PathRef(null);

                Assert.That(() => { pathRef.Clear(); }, Throws.Nothing);
                Assert.That(pathRef.IsNull, Is.True);
                Assert.That(pathRef.IsEmpty, Is.False);
                Assert.That(pathRef.ToString(), Is.Null);
            }
Esempio n. 29
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);
            }
Esempio n. 30
0
        public void When_CreatingWithValidInput(string input, string expectedOutput)
        {
            PathRef pathRef = new PathRef(input);

            Assert.That(pathRef.ToString(), Is.EqualTo(expectedOutput));
        }