Beispiel #1
0
        public void UpdateCommentOnlyOnDisk()
        {
            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                

                string tempFile = GetTempFilePath();
                Assert.IsNotNull(tempFile, "No permission to execute this test?");

                tempFile = Path.Combine(tempFile, "SharpZipTest.Zip");
                if (store.FileExists(tempFile))
                {
                    store.DeleteFile(tempFile);
                }

                using (IsolatedZipFile testFile = IsolatedZipFile.Create(tempFile))
                {
                    testFile.BeginUpdate();
                    testFile.Add(new StringMemoryDataSource("Aha"), "No1", CompressionMethod.Stored);
                    testFile.Add(new StringMemoryDataSource("And so it goes"), "No2", CompressionMethod.Stored);
                    testFile.Add(new StringMemoryDataSource("No3"), "No3", CompressionMethod.Stored);
                    testFile.CommitUpdate();

                    // TODO: Testing is not yet ported -  Assert.IsTrue(testFile.TestArchive(true));
                }

                using (IsolatedZipFile testFile = new IsolatedZipFile(tempFile))
                {
                    // TODO: Testing is not yet ported - Assert.IsTrue(testFile.TestArchive(true));
                    Assert.AreEqual("", testFile.ZipFileComment);

                    testFile.BeginUpdate(new IsolatedDiskArchiveStorage(testFile, FileUpdateMode.Direct));
                    testFile.SetComment("Here is my comment");
                    testFile.CommitUpdate();

                    // TODO: Testing is not yet ported - Assert.IsTrue(testFile.TestArchive(true));
                }

                using (IsolatedZipFile testFile = new IsolatedZipFile(tempFile))
                {
                    // TODO: Testing is not yet ported - Assert.IsTrue(testFile.TestArchive(true));
                    Assert.AreEqual("Here is my comment", testFile.ZipFileComment);
                }
                store.DeleteFile(tempFile);

                // Variant using indirect updating.
                using (IsolatedZipFile testFile = IsolatedZipFile.Create(tempFile))
                {
                    testFile.BeginUpdate();
                    testFile.Add(new StringMemoryDataSource("Aha"), "No1", CompressionMethod.Stored);
                    testFile.Add(new StringMemoryDataSource("And so it goes"), "No2", CompressionMethod.Stored);
                    testFile.Add(new StringMemoryDataSource("No3"), "No3", CompressionMethod.Stored);
                    testFile.CommitUpdate();

                    // TODO: Testing is not yet ported - Assert.IsTrue(testFile.TestArchive(true));
                }

                using (IsolatedZipFile testFile = new IsolatedZipFile(tempFile))
                {
                    // TODO: Testing is not yet ported - Assert.IsTrue(testFile.TestArchive(true));
                    Assert.AreEqual("", testFile.ZipFileComment);

                    testFile.BeginUpdate();
                    testFile.SetComment("Here is my comment");
                    testFile.CommitUpdate();

                    // TODO: Testing is not yet ported - Assert.IsTrue(testFile.TestArchive(true));
                }

                using (IsolatedZipFile testFile = new IsolatedZipFile(tempFile))
                {
                    // TODO: Testing is not yet ported - Assert.IsTrue(testFile.TestArchive(true));
                    Assert.AreEqual("Here is my comment", testFile.ZipFileComment);
                }

                store.DeleteFile(tempFile);
                store.DeleteDirectory(Path.GetDirectoryName(tempFile));

            }
        }
Beispiel #2
0
        public void UpdateCommentOnlyOnDisk()
        {
            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                string tempFile = GetTempFilePath();
                Assert.IsNotNull(tempFile, "No permission to execute this test?");

                tempFile = Path.Combine(tempFile, "SharpZipTest.Zip");
                if (store.FileExists(tempFile))
                {
                    store.DeleteFile(tempFile);
                }

                using (IsolatedZipFile testFile = IsolatedZipFile.Create(tempFile))
                {
                    testFile.BeginUpdate();
                    testFile.Add(new StringMemoryDataSource("Aha"), "No1", CompressionMethod.Stored);
                    testFile.Add(new StringMemoryDataSource("And so it goes"), "No2", CompressionMethod.Stored);
                    testFile.Add(new StringMemoryDataSource("No3"), "No3", CompressionMethod.Stored);
                    testFile.CommitUpdate();

                    // TODO: Testing is not yet ported -  Assert.IsTrue(testFile.TestArchive(true));
                }

                using (IsolatedZipFile testFile = new IsolatedZipFile(tempFile))
                {
                    // TODO: Testing is not yet ported - Assert.IsTrue(testFile.TestArchive(true));
                    Assert.AreEqual("", testFile.ZipFileComment);

                    testFile.BeginUpdate(new IsolatedDiskArchiveStorage(testFile, FileUpdateMode.Direct));
                    testFile.SetComment("Here is my comment");
                    testFile.CommitUpdate();

                    // TODO: Testing is not yet ported - Assert.IsTrue(testFile.TestArchive(true));
                }

                using (IsolatedZipFile testFile = new IsolatedZipFile(tempFile))
                {
                    // TODO: Testing is not yet ported - Assert.IsTrue(testFile.TestArchive(true));
                    Assert.AreEqual("Here is my comment", testFile.ZipFileComment);
                }
                store.DeleteFile(tempFile);

                // Variant using indirect updating.
                using (IsolatedZipFile testFile = IsolatedZipFile.Create(tempFile))
                {
                    testFile.BeginUpdate();
                    testFile.Add(new StringMemoryDataSource("Aha"), "No1", CompressionMethod.Stored);
                    testFile.Add(new StringMemoryDataSource("And so it goes"), "No2", CompressionMethod.Stored);
                    testFile.Add(new StringMemoryDataSource("No3"), "No3", CompressionMethod.Stored);
                    testFile.CommitUpdate();

                    // TODO: Testing is not yet ported - Assert.IsTrue(testFile.TestArchive(true));
                }

                using (IsolatedZipFile testFile = new IsolatedZipFile(tempFile))
                {
                    // TODO: Testing is not yet ported - Assert.IsTrue(testFile.TestArchive(true));
                    Assert.AreEqual("", testFile.ZipFileComment);

                    testFile.BeginUpdate();
                    testFile.SetComment("Here is my comment");
                    testFile.CommitUpdate();

                    // TODO: Testing is not yet ported - Assert.IsTrue(testFile.TestArchive(true));
                }

                using (IsolatedZipFile testFile = new IsolatedZipFile(tempFile))
                {
                    // TODO: Testing is not yet ported - Assert.IsTrue(testFile.TestArchive(true));
                    Assert.AreEqual("Here is my comment", testFile.ZipFileComment);
                }

                store.DeleteFile(tempFile);
                store.DeleteDirectory(Path.GetDirectoryName(tempFile));
            }
        }