示例#1
0
        public void GZipMemberEntry_GetAllMemberEntriesFromStreamContainingOneGZipWithMaxLimitFour_GetsOneEntry()
        {
            using (var stream = TestResource.TagalongCfgGZip.OpenResourceForReading())
            {
                var entries = GZipMemberEntry.GetMemberEntries(stream, maxNumberOfEntries: 4).ToList();

                Assert.Equal(1, entries.Count);
            }
        }
示例#2
0
        public void GZipMemberEntry_GetAllMemberEntriesFromStreamContainingTwoConcatenatedGZipsWithMaxLimitThree_GetsTwoEntries()
        {
            using (var stream = TestResource.TagalongBinCfgNYGZip.OpenResourceForReading())
            {
                var entries = GZipMemberEntry.GetMemberEntries(stream, maxNumberOfEntries: 3).ToList();

                Assert.Equal(2, entries.Count);
            }
        }
示例#3
0
        public void GZipMemberEntry_GetAllMemberEntriesFromStreamContainingConcatenatedGZipsWithMaxLimitZero_GetsZeroEntries()
        {
            using (var stream = TestResource.TagalongBCLRNYNYGZip.OpenResourceForReading())
            {
                var entries = GZipMemberEntry.GetMemberEntries(stream, maxNumberOfEntries: 0);

                Assert.False(entries.Any());
            }
        }
示例#4
0
        public void GZipMemberEntry_GetAllMemberEntriesFromGZipContainingFileNames_GetsMemberExpectedEntryData(TestResource testResource, long expectedLength, uint expectedCrc32)
        {
            using (var stream = testResource.OpenResourceForReading())
            {
                var entry = GZipMemberEntry.GetMemberEntries(stream).Single();

                VerifyGZipMemberEntry(entry, testResource.ArchiveContents.First(), expectedCrc32, expectedLength, GZipOS.Unix);
            }
        }
示例#5
0
        public void GZipMemberEntry_GetAllMemberEntriesFromBadStream_OnlyReturnsSomeEntries()
        {
            string testResourcePath;

            using (TestResource.TagalongBinCfgYYGZip.ExtractToTemporaryFile(out testResourcePath))
                using (var stream = new TestFileStream(testResourcePath, FileMode.Open, FileAccess.Read))
                {
                    var entries = GZipMemberEntry.GetMemberEntries(stream);

                    Assert.True(entries.Count() < 2);
                }
        }
示例#6
0
        public void GZipMemberEntry_GetAllMemberEntriesFromStreamContainingTwoConcatenatedGZips_GetsMembersWithExpectedEntryNames(TestResource testResource, IEnumerable <VerificationData> verificationData)
        {
            using (var stream = testResource.OpenResourceForReading())
            {
                var entries           = GZipMemberEntry.GetMemberEntries(stream).ToList();
                var verifyEntriesData = verificationData.ToList();

                for (var i = 0; i < entries.Count; ++i)
                {
                    var verifyData = verifyEntriesData[i];
                    VerifyGZipMemberEntry(entries[i], verifyData.ExpectedName, verifyData.ExpectedCrc32, verifyData.ExpectedLength, checkModificationDate: verifyData.CheckLastModificationTime);
                }
            }
        }
示例#7
0
        public void GZipMemberEntry_GetAllMemberEntriesFromFile_GetsMembersWithExpectedEntryNames(TestResource testResource)
        {
            IEnumerable <GZipMemberEntry> entries = null;
            string testResourcePath;

            using (testResource.ExtractToTemporaryFile(out testResourcePath))
                using (var stream = new FileStream(testResourcePath, FileMode.Open, FileAccess.Read))
                {
                    entries = GZipMemberEntry.GetMemberEntries(stream);
                }

            // .cfg file CRCs are zero because they are inconsistent based on line endings.
            // .luigi file CRCs are zero merely because they haven't been computed :P
            var expectedCrc32s = new[] { TestRomResources.TestBinCrc, 0u, 0u, TestRomResources.TestRomCrc };
            var expectedNames  = testResource.ArchiveContents.ToList();
            var i = 0;

            foreach (var entry in entries)
            {
                // Expected length is loosely checked -- any value indicates a > 0 check.
                VerifyGZipMemberEntry(entry, expectedNames[i], expectedCrc32s[i], expectedLength: 2, checkModificationDate: false, checkOffset: i > 0);
                ++i;
            }
        }
示例#8
0
 public void GZipMemberEntry_GetAllMemberEntriesWithNullStream_ThrowsNullReferenceException()
 {
     Assert.Throws <NullReferenceException>(() => GZipMemberEntry.GetMemberEntries(null));
 }