コード例 #1
0
        public void checkTest2()
        {
            var target = new SevenZipComponentCheckArchiveAccessor();

            try {
                target.parse("[7z  check(\"thisisreallyisnotrealfile.zip\")]");
                Assert.Fail("1");
            }
            catch (Exception ex) { Assert.IsTrue(ex.GetType() == typeof(NotFoundException), ex.GetType().ToString()); }

            try {
                target.parse("[7z  check(\" \")]");
                Assert.Fail("2");
            }
            catch (Exception ex) { Assert.IsTrue(ex.GetType() == typeof(InvalidArgumentException), ex.GetType().ToString()); }

            using (var tf = new TempFile(false, ".zip")) {
                target.parse("[7z  check(\"" + tf.file + "\")]");
                Assert.AreEqual(target.location(tf.file), target.file);
                Assert.AreEqual(null, target.pwd);
            }

            using (var tf = new TempFile(false, ".zip")) {
                target.parse("[7z  check(\"" + tf.file + "\", \"pass-123\")]");
                Assert.AreEqual(target.location(tf.file), target.file);
                Assert.AreEqual("pass-123", target.pwd);
            }
        }
コード例 #2
0
        public void checkTest2()
        {
            var target = new SevenZipComponentCheckArchiveAccessor();

            try {
                target.parse("[7z  check(\"thisisreallyisnotrealfile.zip\")]");
                Assert.Fail("1");
            }
            catch(Exception ex) { Assert.IsTrue(ex.GetType() == typeof(NotFoundException), ex.GetType().ToString()); }

            try {
                target.parse("[7z  check(\" \")]");
                Assert.Fail("2");
            }
            catch(Exception ex) { Assert.IsTrue(ex.GetType() == typeof(InvalidArgumentException), ex.GetType().ToString()); }

            using(var tf = new TempFile(false, ".zip")) {
                target.parse("[7z  check(\""+ tf.file +"\")]");
                Assert.AreEqual(target.location(tf.file), target.file);
                Assert.AreEqual(null, target.pwd);
            }

            using(var tf = new TempFile(false, ".zip")) {
                target.parse("[7z  check(\"" + tf.file + "\", \"pass-123\")]");
                Assert.AreEqual(target.location(tf.file), target.file);
                Assert.AreEqual("pass-123", target.pwd);
            }
        }