Esempio n. 1
0
        public void ShouldAddFiles2()
        {
            using (var jarFileWriter = new JarFile(FileAccessMode.Write, jarFiledata))
            {
                header["FileName"] = file1;
                jarFileWriter.AddFile(new JarFileItem(header, file1));

                header["FileName"] = file2;
                jarFileWriter.AddFile(new JarFileItem(header, file2));
            }

            using (var jarFileReader = new JarFile(FileAccessMode.Read, jarFiledata))
            {
                Assert.AreEqual(2, jarFileReader.FilesCount);
                var jarItem1 = jarFileReader.GetNextFile();

                var jarItem2 = jarFileReader.GetNextFile();

                Assert.AreEqual("TestData1", System.Text.Encoding.UTF8.GetString(jarItem1.Containt));
                Assert.AreEqual("TestData2", System.Text.Encoding.UTF8.GetString(jarItem2.Containt));
            }
        }
Esempio n. 2
0
        public void ShouldThrowExceptionForInvalidModeOpretion()
        {
            using (var jarFileWriter = new JarFile(FileAccessMode.Write, jarFiledata))
            {
                jarFileWriter.AddFile(new JarFileItem(header, file1));

                Assert.Throws <InvalidOperationException>(() => jarFileWriter.GetNextFile());
            }

            using (var jarFileReader = new JarFile(FileAccessMode.Read, jarFiledata))
            {
                Assert.Throws <InvalidOperationException>(() => jarFileReader.AddFile(new JarFileItem(header, file1)));
            }
        }