Exemple #1
0
 public void ChangeExtension()
 {
     Assert.Equal("test.one", LinuxPath.ChangeExtension("test", "one"));
     Assert.Equal("test.one", LinuxPath.ChangeExtension("test.zero", "one"));
     Assert.Equal("/foo/test.one", LinuxPath.ChangeExtension("\\foo\\test", "one"));
     Assert.Equal("/foo/test.one", LinuxPath.ChangeExtension("\\foo\\test.zero", "one"));
 }
Exemple #2
0
        public void ChangeExtensionTest()
        {
            String result = LinuxPath.ChangeExtension("/system/busybox", "foo");

            Assert.AreEqual <string>("/system/busybox.foo", result);

            result = LinuxPath.ChangeExtension("/system/xbin/file.ext", "myext");
            Assert.AreEqual <string>("/system/xbin/file.myext", result);

            result = LinuxPath.ChangeExtension("/system/xbin/file.ext", "");
            Assert.AreEqual <string>("/system/xbin/file", result);

            result = LinuxPath.ChangeExtension("/system/busybox.foo", "");
            Assert.AreEqual <string>("/system/busybox", result);
        }
Exemple #3
0
        public void WhenPathContainsInvalidCharacter_ShouldThrowArgumentException( )
        {
            int errorCount = 0;

            for (var x = 0; x < LinuxPathConsts.InvalidPathChars.Length; ++x)
            {
                try {
                    string result = LinuxPath.ChangeExtension("/my-invalid-path/f-{0}".With(LinuxPathConsts.InvalidPathChars[x]), "ext");
                } catch (ArgumentException) {
                    errorCount++;
                }
            }

            Assert.Equal(LinuxPathConsts.InvalidPathChars.Length, errorCount);
        }
Exemple #4
0
        public void WhenPathHasNoExtension_ShouldReturnPathWithExtension( )
        {
            string result = LinuxPath.ChangeExtension("/my-path/to/file", ".ext2");

            Assert.Equal("/my-path/to/file.ext2", result);
        }
Exemple #5
0
        public void WhenExtensionStartsWithDot_ShouldReturnChangedExtension( )
        {
            string result = LinuxPath.ChangeExtension("/my-path/to/file.ext1", ".ext2");

            Assert.Equal("/my-path/to/file.ext2", result);
        }
Exemple #6
0
        public void WhenExtensionIsEmpty_ShouldReturnPath( )
        {
            string result = LinuxPath.ChangeExtension("/my-path/to/file.ext1", string.Empty);

            Assert.Equal("/my-path/to/file.ext1", result);
        }
Exemple #7
0
        public void WhenPathLengthIsZero_ShouldReturnEmpty()
        {
            string result = LinuxPath.ChangeExtension(string.Empty, "ext");

            Assert.Equal(string.Empty, result);
        }
Exemple #8
0
        public void WhenPathIsNull_ShouldReturnNull()
        {
            string result = LinuxPath.ChangeExtension(null, "ext");

            Assert.Null(result);
        }