public void WhenPathIsNull_ShouldReturnNull( )
        {
            var fixture = new Fixture( );
            var result  = LinuxPath.GetFileNameWithoutExtension(null);

            Assert.Null(result);
        }
        public void WhenPathIsDirectory_ShouldReturnEmpty( )
        {
            var fixture = new Fixture( );
            var p1      = fixture.Create("/path1-");
            var p2      = "{0}/".With(fixture.Create("path2-"));
            var p       = LinuxPath.Combine(p1, p2);
            var result  = LinuxPath.GetFileNameWithoutExtension(p);

            Assert.Equal(string.Empty, result);
        }
        public void WhenPathHasFileWithoutExtension_ShouldReturnFileWithoutExtension( )
        {
            var fixture = new Fixture( );
            var p1      = fixture.Create("/path1-");
            var p2      = "{0}/".With(fixture.Create("path2-"));
            var f       = "{0}".With(fixture.Create("file-"));
            var p       = LinuxPath.Combine(p1, p2, f);
            var result  = LinuxPath.GetFileNameWithoutExtension(p);

            Assert.Equal(f, result);
        }
Esempio n. 4
0
        public void GetFileNameWithoutExtensionTest()
        {
            String result = LinuxPath.GetFileNameWithoutExtension("/system/busybox");

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

            result = LinuxPath.GetFileNameWithoutExtension("/");
            Assert.AreEqual <string>("", result);

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

            result = LinuxPath.GetFileNameWithoutExtension("/system/xbin/file.ext");
            Assert.AreEqual <string>("file", result);
        }
        public void WhenPathContainsInvalidCharacter_ShouldThrowArgumentException( )
        {
            var fixture    = new Fixture( );
            int errorCount = 0;

            for (var x = 0; x < LinuxPathConsts.InvalidPathChars.Length; ++x)
            {
                try {
                    string result = LinuxPath.GetFileNameWithoutExtension("/some/path/{0}-{1}.ext".With(LinuxPathConsts.InvalidPathChars[x], fixture.Create("file-")));
                } catch (ArgumentException) {
                    errorCount++;
                }
            }

            Assert.Equal(LinuxPathConsts.InvalidPathChars.Length, errorCount);
        }
Esempio n. 6
0
 public void GetFileNameWithoutExtension()
 {
     Assert.Equal("three", LinuxPath.GetFileNameWithoutExtension("\\one\\two\\three.txt"));
     Assert.Equal("three", LinuxPath.GetFileNameWithoutExtension("/one/two/three.txt"));
 }