Пример #1
0
        public void FindEntry()
        {
            string tempFile = GetTempFilePath();

            Assert.IsNotNull(tempFile, "No permission to execute this test?");
            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                tempFile = Path.Combine(tempFile, "SharpZipTest.Zip");
                MakeZipFile(tempFile, new string[] { "Farriera", "Champagne", "Urban myth" }, 10, "Aha");

                using (IsolatedZipFile zipFile = new IsolatedZipFile(tempFile))
                {
                    Assert.AreEqual(3, zipFile.Count, "Expected 1 entry");

                    int testIndex = zipFile.FindEntry("Farriera", false);
                    Assert.AreEqual(0, testIndex, "Case sensitive find failure");
                    Assert.IsTrue(string.Compare(zipFile[testIndex].Name, "Farriera", StringComparison.InvariantCulture) == 0);


                    testIndex = zipFile.FindEntry("farriera", false);
                    Assert.AreEqual(-1, testIndex, "Case sensitive find failure");


                    testIndex = zipFile.FindEntry("farriera", true);
                    Assert.AreEqual(0, testIndex, "Case insensitive find failure");
                    Assert.IsTrue(string.Compare(zipFile[testIndex].Name, "Farriera", StringComparison.InvariantCultureIgnoreCase) == 0);

                    testIndex = zipFile.FindEntry("urban mYTH", false);
                    Assert.AreEqual(-1, testIndex, "Case sensitive find failure");

                    testIndex = zipFile.FindEntry("urban mYTH", true);
                    Assert.AreEqual(2, testIndex, "Case insensitive find failure");
                    Assert.IsTrue(string.Compare(zipFile[testIndex].Name, "urban mYTH", StringComparison.InvariantCultureIgnoreCase) == 0);

                    testIndex = zipFile.FindEntry("Champane.", false);
                    Assert.AreEqual(-1, testIndex, "Case sensitive find failure");

                    testIndex = zipFile.FindEntry("Champane.", true);
                    Assert.AreEqual(-1, testIndex, "Case insensitive find failure");

                    zipFile.Close();
                }
                store.DeleteFile(tempFile);
            }
        }
Пример #2
0
        public void FindEntry()
        {
            string tempFile = GetTempFilePath();
            Assert.IsNotNull(tempFile, "No permission to execute this test?");
            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                tempFile = Path.Combine(tempFile, "SharpZipTest.Zip");
                MakeZipFile(tempFile, new string[] { "Farriera", "Champagne", "Urban myth" }, 10, "Aha");

                using (IsolatedZipFile zipFile = new IsolatedZipFile(tempFile))
                {
                    Assert.AreEqual(3, zipFile.Count, "Expected 1 entry");

                    int testIndex = zipFile.FindEntry("Farriera", false);
                    Assert.AreEqual(0, testIndex, "Case sensitive find failure");
                    Assert.IsTrue(string.Compare(zipFile[testIndex].Name, "Farriera", StringComparison.InvariantCulture) == 0);


                    testIndex = zipFile.FindEntry("farriera", false);
                    Assert.AreEqual(-1, testIndex, "Case sensitive find failure");


                    testIndex = zipFile.FindEntry("farriera", true);
                    Assert.AreEqual(0, testIndex, "Case insensitive find failure");
                    Assert.IsTrue(string.Compare(zipFile[testIndex].Name, "Farriera", StringComparison.InvariantCultureIgnoreCase) == 0);

                    testIndex = zipFile.FindEntry("urban mYTH", false);
                    Assert.AreEqual(-1, testIndex, "Case sensitive find failure");

                    testIndex = zipFile.FindEntry("urban mYTH", true);
                    Assert.AreEqual(2, testIndex, "Case insensitive find failure");
                    Assert.IsTrue(string.Compare(zipFile[testIndex].Name, "urban mYTH", StringComparison.InvariantCultureIgnoreCase) == 0);

                    testIndex = zipFile.FindEntry("Champane.", false);
                    Assert.AreEqual(-1, testIndex, "Case sensitive find failure");

                    testIndex = zipFile.FindEntry("Champane.", true);
                    Assert.AreEqual(-1, testIndex, "Case insensitive find failure");

                    zipFile.Close();
                }
                store.DeleteFile(tempFile);
            }
        }