Beispiel #1
0
        public void CreateHeaderFromFile_ItemIsNotCompressed_ItemCreated()
        {
            var nefs   = TestArchiveNotModified.Create(@"C:\archive.nefs");
            var itemId = new NefsItemId(TestArchiveNotModified.File3ItemId);
            var item   = NefsItem.CreateFromHeader(itemId, nefs.Header, nefs.Items);

            // File3 is not compressed
            var expected = nefs.Items.GetItem(itemId);

            Assert.Equal(expected.CompressedSize, item.CompressedSize);
            Assert.Equal(expected.DirectoryId, item.DirectoryId);
            Assert.Equal(expected.ExtractedSize, item.ExtractedSize);
            Assert.Equal(expected.FileName, item.FileName);
            Assert.Equal(expected.Id, item.Id);
            Assert.Equal(expected.State, item.State);
            Assert.Equal(NefsItemType.File, item.Type);
            Assert.Equal(@"C:\archive.nefs", item.DataSource.FilePath);
            Assert.Equal(expected.DataSource.Offset, item.DataSource.Offset);
            Assert.False(item.DataSource.ShouldCompress);
            Assert.Single(item.DataSource.Size.ChunkSizes);
            Assert.Equal(expected.ExtractedSize, item.DataSource.Size.ChunkSizes[0]);
            Assert.Equal(expected.ExtractedSize, item.DataSource.Size.ExtractedSize);
            Assert.False(item.DataSource.Size.IsCompressed);
            Assert.Equal(expected.CompressedSize, item.DataSource.Size.Size);
        }
Beispiel #2
0
        public void Clone_ItemCloned()
        {
            var nefs   = TestArchiveNotModified.Create(@"C:\archive.nefs");
            var itemId = new NefsItemId(TestArchiveNotModified.File3ItemId);
            var item   = NefsItem.CreateFromHeader(itemId, nefs.Header, nefs.Items);

            item.UpdateState(NefsItemState.Replaced);

            var clone = item.Clone() as NefsItem;

            Assert.Equal(item.CompressedSize, clone.CompressedSize);
            Assert.Same(item.DataSource, clone.DataSource);
            Assert.Equal(item.DirectoryId, clone.DirectoryId);
            Assert.Equal(item.ExtractedSize, clone.ExtractedSize);
            Assert.Equal(item.FileName, clone.FileName);
            Assert.Equal(item.Id, clone.Id);
            Assert.Equal(item.Part6Unknown0x00, clone.Part6Unknown0x00);
            Assert.Equal(item.Part6Unknown0x01, clone.Part6Unknown0x01);
            Assert.Equal(item.Part6Unknown0x02, clone.Part6Unknown0x02);
            Assert.Equal(item.Part6Unknown0x03, clone.Part6Unknown0x03);
            Assert.Equal(item.State, clone.State);
            Assert.Equal(item.Type, clone.Type);
        }
Beispiel #3
0
        private NefsItemList CreateItems(string dataFilePath, NefsHeader h)
        {
            var items    = new NefsItemList(dataFilePath);
            var numItems = h.TableOfContents.Part1Size / NefsHeaderPart1Entry.Size;

            for (var i = 0; i < numItems; ++i)
            {
                // Create the item
                var id = new NefsItemId((uint)i);

                try
                {
                    var item = NefsItem.CreateFromHeader(id, h, items);
                    items.Add(item);
                }
                catch (Exception)
                {
                    Log.LogError($"Failed to create item {id}, skipping.");
                }
            }

            return(items);
        }