public void DecodeTest() { MockBitWriter io = new MockBitWriter(); Shannon shannon = new Shannon(io); io.WriteBit(false); io.WriteBit(false); io.WriteBit(false); io.WriteBit(false); io.WriteBit(false); io.WriteBit(true); io.WriteBit(false); io.WriteBit(true); Assert.AreEqual(shannon.Decode(), 5); io.WriteBit(false); io.WriteBit(false); io.WriteBit(false); io.WriteBit(false); io.WriteBit(false); io.WriteBit(false); io.WriteBit(false); Assert.AreEqual(shannon.Decode(), 5); }
public void EncodeDecodeTest() { MockBitWriter io = new MockBitWriter(); Shannon encoder = new Shannon(io); foreach (char character in "Lorem ipsum dolor sit amet consectetur adepiscig nullam") { encoder.Encode(character); } Shannon decoder = new Shannon(io); foreach (char character in "Lorem ipsum dolor sit amet consectetur adepiscig nullam") { Assert.AreEqual(decoder.Decode(), character); } }