public void TestEncodeWriteAndReadDecode() { const string source = "abcdefghklmopqastuvwxyz"; const string fileName = "test1.acode"; var fullPath = Path.Combine(GetTestFolder(), fileName); var encoded = ArithmeticCoding.Encode(source); ArithmeticFile.Write(fullPath, encoded); var read = ArithmeticFile.Read(fullPath); var decoded = ArithmeticCoding.Decode(read); Assert.AreEqual(source, decoded); }
private void BtnSaveCode_Click(object sender, EventArgs e) { if (RtbSource.TextLength == 0) { return; } if (_sdfEncoded.ShowDialog() != DialogResult.OK) { return; } try { var encoded = ArithmeticCoding.Encode(RtbSource.Text); ArithmeticFile.Write(_sdfEncoded.FileName, encoded); } catch (Exception ex) { MessageBox.Show(ex.Message); } }