private void buttonDecode_Click(object sender, EventArgs e) { var fileInfoEncodedFile = new FileInfo(textBoxFilePathEncodedFile.Text); if (!fileInfoEncodedFile.Exists) { throw new InvalidOperationException($"Lz77 decoding error: file '{fileInfoEncodedFile.FullName}' does not exist"); } var encodedFileExtension = GetExtensionOfEncodedFile(fileInfoEncodedFile); var decodedFileDestinationPath = $"{fileInfoEncodedFile.FullName}.{encodedFileExtension}"; using (var fileReader = new FileReader(textBoxFilePathEncodedFile.Text, new Buffer())) { using (var fileWriter = new FileWriter(decodedFileDestinationPath, new Buffer())) { lz77Decoder.DecodeFile(fileReader, fileWriter); } } if (checkBoxShowTokensDecrypting.Checked) { DisplayTokens(lz77Decoder.TokensFromPreviousRun); } }
public void FileIsEncodedThenDecodedCorrectly1() { TestMethods.CreateFileWithTextContents(filePathSource, Constants.FileContents); using (var fileReader = new FileReader(filePathSource, new Buffer())) { using (var fileWriter = new FileWriter(filePathEncodedFile, new Buffer())) { lz77Encoder.EncodeFile(fileReader, fileWriter, Constants.BitsForOffset1, Constants.BitsForLength1); } } using (var fileReader = new FileReader(filePathEncodedFile, new Buffer())) { using (var fileWriter = new FileWriter(filePathDecodedFile, new Buffer())) { lz77Decoder.DecodeFile(fileReader, fileWriter); } } Assert.IsTrue(TestMethods.FilesHaveTheSameContent(filePathSource, filePathDecodedFile)); }