internal static void Main() { // Logging LogHelper.LoggerFactory = new LoggerFactory(); var logConfig = new LoggerConfiguration() .WriteTo.Console() .CreateLogger(); LogHelper.LoggerFactory.AddSerilog(logConfig); NefsLog.LoggerFactory = LogHelper.LoggerFactory; // Setup workspace and services var fileSystem = new FileSystem(); var uiService = new UiService(Dispatcher.CurrentDispatcher, fileSystem); var settingsService = new SettingsService(fileSystem, uiService); var progressService = new ProgressService(uiService); var nefsCompressor = new NefsCompressor(fileSystem); var nefsReader = new NefsReader(fileSystem); var nefsWriter = new NefsWriter(TempDirectory, fileSystem, nefsCompressor); var workspace = new NefsEditWorkspace( fileSystem, progressService, uiService, settingsService, nefsReader, nefsWriter, nefsCompressor); // Run application Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new EditorForm(workspace, uiService, settingsService)); }
public async Task DecompressFileAsync_NotEncrypted_DataDecompressed() { const string Data = @"Hello. This is the input data. It is not encrypted. Hello. This is the input data. It is not encrypted. Hello. This is the input data. It is not encrypted. Hello. This is the input data. It is not encrypted. Hello. This is the input data. It is not encrypted. Hello. This is the input data. It is not encrypted. Hello. This is the input data. It is not encrypted. Hello. This is the input data. It is not encrypted. Hello. This is the input data. It is not encrypted. Hello. This is the input data. It is not encrypted. Hello. This is the input data. It is not encrypted. Hello. This is the input data. It is not encrypted. Hello. This is the input data. It is not encrypted. Hello. This is the input data. It is not encrypted. Hello. This is the input data. It is not encrypted. Hello. This is the input data. It is not encrypted. Hello. This is the input data. It is not encrypted. Hello. This is the input data. It is not encrypted. Hello. This is the input data. It is not encrypted. Hello. This is the input data. It is not encrypted. Hello. This is the input data. It is not encrypted. Hello. This is the input data. It is not encrypted."; var sourceFilePath = @"C:\source.txt"; var compressedFilePath = @"C:\compressed.dat"; var destFilePath = @"C:\dest.txt"; var chunkSize = 0x10000U; this.fileSystem.AddFile(sourceFilePath, new MockFileData(Data)); // Compress the source data var c = new NefsCompressor(this.fileSystem); var size = await c.CompressFileAsync(sourceFilePath, compressedFilePath, chunkSize, new NefsProgress()); // Decompress the data await c.DecompressFileAsync(compressedFilePath, 0, size.ChunkSizes, destFilePath, 0, new NefsProgress()); // Verify var decompressedText = this.fileSystem.File.ReadAllText(destFilePath); Assert.Equal(Data, decompressedText); }
public async Task CompressAsync_VariousData_DataCompressed(CompressAsyncTestData test) { var input = Encoding.ASCII.GetBytes(InputDataString); using (var inputStream = new MemoryStream(input)) using (var outputStream = new MemoryStream()) { var c = new NefsCompressor(this.fileSystem); var size = await c.CompressAsync(inputStream, test.Offset, test.Length, outputStream, 0, test.ChunkSize, new NefsProgress()); // Read data from output stream var resultData = new byte[outputStream.Length]; outputStream.Seek(0, SeekOrigin.Begin); await outputStream.ReadAsync(resultData, 0, (int)outputStream.Length); // Verify Assert.Equal(test.Length, size.ExtractedSize); Assert.Equal(test.ExpectedChunks.Count, size.ChunkSizes.Count); Assert.True(test.ExpectedChunks.SequenceEqual(size.ChunkSizes)); Assert.Equal(test.ExpectedData.Length, resultData.Length); Assert.True(test.ExpectedData.SequenceEqual(resultData)); } }