示例#1
0
        public void WhenPathContainsFile_ShouldReturnPath( )
        {
            var fixture = new Fixture( );
            var p1      = fixture.Create("path1-");
            var p2      = fixture.Create("path2-");
            var f1      = fixture.Create("file-");
            var p       = "/{0}/{1}/{2}".With(p1, p2, f1);
            var result  = LinuxPath.GetPathWithoutFile(p);

            Assert.Equal("/{0}/{1}/".With(p1, p2), result);
        }
示例#2
0
        public void GetPathWithoutFileTest()
        {
            String result = LinuxPath.GetPathWithoutFile("/system/busybox");

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

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

            result = LinuxPath.GetPathWithoutFile("/system/xbin/file.ext");
            Assert.AreEqual <string>("/system/xbin/", result);
        }
示例#3
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.GetPathWithoutFile("/{0}-{1}/".With(LinuxPathConsts.InvalidPathChars[x], fixture.Create("path1")));
                } catch (ArgumentException) {
                    errorCount++;
                }
            }

            Assert.Equal(LinuxPathConsts.InvalidPathChars.Length, errorCount);
        }
示例#4
0
 public void WhenPathIsNull_ShouldReturnNull()
 {
     Assert.Null(LinuxPath.GetPathWithoutFile(null));
 }