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)); }
public void EncodeFileSetsTokensFromPreviousRunAsExpected() { using (var fileReader = new FileReader(filePathFile, new Buffer())) { using (var fileWriter = new FileWriter(filePathEncodedFile, new Buffer())) { lz77Encoder.EncodeFile(fileReader, fileWriter, Constants.BitsForOffset1, Constants.BitsForLength1); } } var comparer = new CompareLogic(); Assert.IsTrue(comparer.Compare(Constants.GetTokens1(), lz77Encoder.TokensFromPreviousRun).AreEqual); }
private void buttonEncode_Click(object sender, EventArgs e) { var bitsForOffset = (int)numericUpDownOffsetBits.Value; var bitsForLength = (int)numericUpDownLengthBits.Value; var destinationFilePath = $"{textBoxFilePathSource.Text}.o[{bitsForOffset}]l[{bitsForLength}].lz77"; using (var fileReader = new FileReader(textBoxFilePathSource.Text, new Buffer())) { using (var fileWriter = new FileWriter(destinationFilePath, new Buffer())) { lz77Encoder.EncodeFile(fileReader, fileWriter, bitsForOffset, bitsForLength); } } if (checkBoxShowTokensEncoding.Checked) { DisplayTokens(lz77Encoder.TokensFromPreviousRun); } }
public void EncodeFileThrowsArgumentNullExceptionForNullFileReader() { lz77Encoder.EncodeFile(null, fileWriterMock.Object, 4, 4); }