예제 #1
0
        public async Task CompressDecompress(PasswordMode mode, CompressionAlgo algo)
        {
            await _externalDependencies.EnsureAllDependenciesPresent();

            string toCompressFolder   = TestFileHelper.NewFolder();
            string compressedFolder   = TestFileHelper.NewFolder();
            string decompressedFolder = TestFileHelper.NewFolder();
            string keysFolder         = TestFileHelper.NewFolder();

            var data = await TestData.CreateFiles(1, 1024, toCompressFolder);

            OperationSummary resultCompress = await Compress(mode, algo, compressedFolder, keysFolder, data);

            resultCompress.ThrowOnError();

            Assert.True(resultCompress.IsSuccess);
            Assert.NotEmpty(resultCompress.OperationBlocks.Select(i => i.Block));
            Assert.NotEmpty(resultCompress.OperationBlocks.Select(i => i.CommandResult));

            var decomp = new TestData {
                Directories = new List <DirectoryInfo> {
                    new DirectoryInfo(compressedFolder)
                }
            };

            OperationSummary resultDecompress = await Decompress(mode, decompressedFolder, keysFolder, decomp);

            resultDecompress.ThrowOnError();

            Assert.True(resultDecompress.IsSuccess);
            Assert.NotEmpty(resultDecompress.OperationBlocks.Select(i => i.Block));
            Assert.NotEmpty(resultDecompress.OperationBlocks.Select(i => i.CommandResult));

            FileInfo src = new DirectoryInfo(toCompressFolder).EnumerateFiles().FirstOrDefault();
            FileInfo dst = new DirectoryInfo(decompressedFolder).EnumerateFiles().FirstOrDefault();

            Assert.True(TestFileHelper.FilesAreEqual(src, dst));
        }