public void GetItemFilePath_FileInRoot_PathReturned()
        {
            var archive = TestArchiveNotModified.Create(@"C:\archive.nefs");
            var path    = archive.Items.GetItemFilePath(new NefsItemId(TestArchiveNotModified.File1ItemId));

            Assert.Equal("file1.txt", path);
        }
Esempio n. 2
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);
        }
        public void GetItemFilePath_DirectoryInRoot_PathReturned()
        {
            var archive = TestArchiveNotModified.Create(@"C:\archive.nefs");
            var path    = archive.Items.GetItemFilePath(new NefsItemId(TestArchiveNotModified.Dir1ItemId));

            Assert.Equal("dir1", path);
        }
Esempio n. 4
0
        public void CreateHeaderFromFile_ItemIsNotCompressed_ItemCreated()
        {
            var nefs = TestArchiveNotModified.Create(@"C:\archive.nefs");
            var item = nefs.Header.CreateItemInfo(TestArchiveNotModified.File3Guid, nefs.Items);

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

            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.True(item.DataSource.IsTransformed);
            Assert.Single(item.DataSource.Size.Chunks);
            Assert.Equal(expected.ExtractedSize, item.DataSource.Size.Chunks[0].CumulativeSize);
            Assert.Equal(expected.ExtractedSize, item.DataSource.Size.Chunks[0].Size);
            Assert.Equal(expected.ExtractedSize, item.DataSource.Size.ExtractedSize);
            Assert.Equal(expected.CompressedSize, item.DataSource.Size.TransformedSize);
            Assert.False(item.DataSource.Size.Chunks[0].Transform.IsZlibCompressed);
            Assert.NotNull(item.Transform);
        }
Esempio n. 5
0
        public async Task WriteArchiveAsync_ArchiveNotModified_ArchiveWritten()
        {
            var sourcePath = @"C:\archive.nefs";
            var destPath   = @"C:\dest.nefs";

            this.fileSystem.AddFile(sourcePath, new MockFileData("hi"));
            var sourceArchive = TestArchiveNotModified.Create(sourcePath);
            var writer        = this.CreateWriter();
            var archive       = await writer.WriteArchiveAsync(@"C:\dest.nefs", sourceArchive, new NefsProgress());

            Assert.Equal(sourceArchive.Items.Count, archive.Items.Count);

            // Try to read archive again
            var reader      = new NefsReader(this.fileSystem);
            var readArchive = await reader.ReadArchiveAsync(destPath, new NefsProgress());

            Assert.Equal(sourceArchive.Items.Count, readArchive.Items.Count);
        }
Esempio n. 6
0
        public void CreateHeaderFromFile_ItemIsDirectory_ItemCreated()
        {
            var nefs = TestArchiveNotModified.Create(@"C:\archive.nefs");
            var item = nefs.Header.CreateItemInfo(TestArchiveNotModified.Dir1Guid, nefs.Items);

            var expected = nefs.Items.GetItem(item.Guid);

            Assert.Equal(0U, item.CompressedSize);
            Assert.Equal(expected.DirectoryId, item.DirectoryId);
            Assert.Equal(0U, item.ExtractedSize);
            Assert.Equal(expected.FileName, item.FileName);
            Assert.Equal(expected.Id, item.Id);
            Assert.Equal(expected.State, item.State);
            Assert.Equal(NefsItemType.Directory, item.Type);
            Assert.Equal("", item.DataSource.FilePath);
            Assert.Equal(0U, item.DataSource.Offset);
            Assert.True(item.DataSource.IsTransformed);
            Assert.Empty(item.DataSource.Size.Chunks);
            Assert.Equal(0U, item.DataSource.Size.ExtractedSize);
            Assert.Equal(0U, item.DataSource.Size.TransformedSize);
            Assert.Null(item.Transform);
        }
Esempio n. 7
0
        public void Clone_ItemCloned()
        {
            var nefs = TestArchiveNotModified.Create(@"C:\archive.nefs");
            var item = nefs.Header.CreateItemInfo(TestArchiveNotModified.File3Guid, 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);
        }