Exemplo n.º 1
0
        public static void TestCompressionEngineNullParams(
            CompressionEngine engine,
            ArchiveFileStreamContext streamContext,
            string[] testFiles)
        {
            Exception caughtEx;

            Console.WriteLine("Testing null streamContext.");
            caughtEx = null;
            try
            {
                engine.Pack(null, testFiles);
            }
            catch (Exception ex) { caughtEx = ex; }
            Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx);
            caughtEx = null;
            try
            {
                engine.Pack(null, testFiles, 0);
            }
            catch (Exception ex) { caughtEx = ex; }
            Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx);

            Console.WriteLine("Testing null files.");
            caughtEx = null;
            try
            {
                engine.Pack(streamContext, null);
            }
            catch (Exception ex) { caughtEx = ex; }
            Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx);

            Console.WriteLine("Testing null files.");
            caughtEx = null;
            try
            {
                engine.Pack(streamContext, null, 0);
            }
            catch (Exception ex) { caughtEx = ex; }
            Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx);


            Console.WriteLine("Testing null stream.");
            caughtEx = null;
            try
            {
                engine.IsArchive(null);
            }
            catch (Exception ex) { caughtEx = ex; }
            Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx);
            caughtEx = null;
            try
            {
                engine.FindArchiveOffset(null);
            }
            catch (Exception ex) { caughtEx = ex; }
            Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx);
            caughtEx = null;
            try
            {
                engine.GetFiles(null);
            }
            catch (Exception ex) { caughtEx = ex; }
            Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx);
            caughtEx = null;
            try
            {
                engine.GetFileInfo(null);
            }
            catch (Exception ex) { caughtEx = ex; }
            Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx);
            caughtEx = null;
            try
            {
                engine.Unpack(null, "testUnpack.txt");
            }
            catch (Exception ex) { caughtEx = ex; }
            Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx);
            Console.WriteLine("Testing null streamContext.");
            caughtEx = null;
            try
            {
                engine.GetFiles(null, null);
            }
            catch (Exception ex) { caughtEx = ex; }
            Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx);
            caughtEx = null;
            try
            {
                engine.GetFileInfo(null, null);
            }
            catch (Exception ex) { caughtEx = ex; }
            Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx);
            caughtEx = null;
            try
            {
                engine.Unpack((IUnpackStreamContext)null, null);
            }
            catch (Exception ex) { caughtEx = ex; }
            Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException), "Caught exception: " + caughtEx);
        }