Exemplo n.º 1
0
        public void WhenPathDoesNotFile_ShouldReturnEmpty( )
        {
            var    fixture = new Fixture( );
            string result  = LinuxPath.GetExtension("/some/path/{0}/".With(fixture.Create("path-")));

            Assert.Equal(string.Empty, result);
        }
Exemplo n.º 2
0
        public void WhenFilePathEndsWithDot_ShouldReturnEmpty( )
        {
            var    fixture = new Fixture( );
            string result  = LinuxPath.GetExtension("/some/path/{0}.".With(fixture.Create("file-")));

            Assert.Equal(string.Empty, result);
        }
Exemplo n.º 3
0
        public void WhenFilePathContainsExtension_ShouldReturnExtension()
        {
            var    fixture = new Fixture( );
            string result  = LinuxPath.GetExtension("/some/path/{0}.ext".With(fixture.Create("file-")));

            Assert.Equal(".ext", result);
        }
Exemplo n.º 4
0
        public void GetFileNameExtensionTest()
        {
            String result = LinuxPath.GetExtension("/system/busybox");

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

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

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

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

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

            Assert.Equal(LinuxPathConsts.InvalidPathChars.Length, errorCount);
        }
Exemplo n.º 6
0
 public void GetExtension()
 {
     Assert.Equal(".txt", LinuxPath.GetExtension("\\one\\two\\three.txt"));
     Assert.Equal(".txt", LinuxPath.GetExtension("/one/two/three.txt"));
 }
Exemplo n.º 7
0
 public void WhenPathIsNull_ShouldReturnNull()
 {
     Assert.Null(LinuxPath.GetExtension(null));
 }