Exemplo n.º 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"));
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
        public void WhenPathHasNoExtension_ShouldReturnPathWithExtension( )
        {
            string result = LinuxPath.ChangeExtension("/my-path/to/file", ".ext2");

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

            Assert.Equal("/my-path/to/file.ext2", result);
        }
Exemplo n.º 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);
        }
Exemplo n.º 7
0
        public void WhenPathLengthIsZero_ShouldReturnEmpty()
        {
            string result = LinuxPath.ChangeExtension(string.Empty, "ext");

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

            Assert.Null(result);
        }