Beispiel #1
0
        public void FromTest()
        {
            IEnumerable <GgpkRecord> records = GgpkRecords.From(@"pass.ggpk");

            Assert.AreEqual <int>(6, records.Count());
            Assert.AreEqual <int>(1, records.OfType <GgpkMainRecord>().Count());
            Assert.AreEqual <int>(2, records.OfType <GgpkDirectoryRecord>().Count());
            Assert.AreEqual <int>(2, records.OfType <GgpkFileRecord>().Count());
            Assert.AreEqual <int>(1, records.OfType <GgpkFreeRecord>().Count());

            GgpkMainRecord      mainRecord  = records.OfType <GgpkMainRecord>().FirstOrDefault();
            GgpkDirectoryRecord dirRecord   = records.OfType <GgpkDirectoryRecord>().Where(d => d.DirectoryName.Length > 0).FirstOrDefault();
            GgpkFileRecord      fileRecord1 = records.OfType <GgpkFileRecord>().Where(r => r.Offset == 28).FirstOrDefault();
            GgpkFileRecord      fileRecord2 = records.OfType <GgpkFileRecord>().Where(r => r.Offset == 108).FirstOrDefault();
            GgpkFreeRecord      freeRecord  = records.OfType <GgpkFreeRecord>().FirstOrDefault();

            Assert.AreEqual <int>(2, mainRecord.RecordOffsets.Count());

            Assert.AreEqual <string>("Dir_1", dirRecord.DirectoryName);
            Assert.AreEqual <int>(2, dirRecord.Entries.Count());

            Assert.AreEqual <string>("test-file-1.bin", fileRecord1.FileName);
            Assert.AreEqual <ulong>(4, fileRecord1.FileLength);

            Assert.AreEqual <string>("Aa_Bb-Cc.DdEe", fileRecord2.FileName);
            Assert.AreEqual <ulong>(6, fileRecord2.FileLength);

            Assert.AreEqual <ulong>(0, freeRecord.NextFreeRecordOffset);

            foreach (GgpkRecord record in records)
            {
                Assert.AreNotEqual <string>(string.Empty, record.ToString());
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            IEnumerable <GgpkRecord> records = GgpkRecords.From(Path.Combine(Environment.GetEnvironmentVariable("POE_PATH"), "content.ggpk"));

            foreach (GgpkRecord record in records)
            {
                Console.WriteLine($"Record: {record.GetType()} @ offset {record.Offset} (length: {record.Length})");
            }
        }
Beispiel #3
0
        public void TestRecords()
        {
            string poePath = Environment.GetEnvironmentVariable("POE_PATH");

            if (string.IsNullOrEmpty(poePath))
            {
                Assert.Inconclusive("Environment variable POE_PATH not defined - skipping test");
            }

            string contentFile = Path.Combine(poePath, "content.ggpk");

            if (!File.Exists(contentFile))
            {
                Assert.Inconclusive("content.ggpk not found - skipping test");
            }

            IEnumerable <GgpkRecord> records = GgpkRecords.From(contentFile);

            Assert.IsTrue(records.Any());
        }
Beispiel #4
0
 public void FromFileNotExistsTest()
 {
     IEnumerable <GgpkRecord> records = GgpkRecords.From(new FileInfo(@"C:\i_do_not_exist.test"));
 }
Beispiel #5
0
 public void FromStreamNullTest()
 {
     IEnumerable <GgpkRecord> records = GgpkRecords.From((Stream)null);
 }
Beispiel #6
0
 public void FromFileNullTest()
 {
     IEnumerable <GgpkRecord> records = GgpkRecords.From((FileInfo)null);
 }
Beispiel #7
0
 public void FromStringNotExistsTest()
 {
     IEnumerable <GgpkRecord> records = GgpkRecords.From(@"C:\i_do_not_exist.test");
 }
Beispiel #8
0
 public void FromStringNullTest()
 {
     IEnumerable <GgpkRecord> records = GgpkRecords.From((string)null);
 }
Beispiel #9
0
 public void FromFileWrongMarkerTest()
 {
     IEnumerable <GgpkRecord> records = GgpkRecords.From(@"fail-marker.ggpk");
 }
Beispiel #10
0
 public void FromFileWrongLengthTest()
 {
     IEnumerable <GgpkRecord> records = GgpkRecords.From(@"fail-length.ggpk");
 }