public void KnownString_SameStringCanBeAddedTwice() { WellknownStringDecoder decoder = new WellknownStringDecoder(); decoder.AddWellknownString("abc"); decoder.AddWellknownString("abc"); }
public void KnownString_UsedInEncoder() { try { WellknownStringDecoder decoder = new WellknownStringDecoder(); decoder.AddWellknownString("abc"); Encoder.StringDecoder = decoder; ByteBuffer buffer = new ByteBuffer(128, true); Encoder.WriteString(buffer, "abc", true); Encoder.WriteString(buffer, "abc", true); buffer.Seek(0); string decodedString1 = Encoder.ReadString(buffer, Encoder.ReadFormatCode(buffer)); string decodedString2 = Encoder.ReadString(buffer, Encoder.ReadFormatCode(buffer)); Assert.IsTrue(ReferenceEquals(decodedString1, decodedString2)); } finally { Encoder.StringDecoder = null; } }
public void KnownString_SameInstanceReturned() { WellknownStringDecoder decoder = new WellknownStringDecoder(); decoder.AddWellknownString("abc"); byte[] encodedBytes = Encoding.UTF8.GetBytes("abc"); string decodedString1 = decoder.DecodeString(new ArraySegment <byte>(encodedBytes)); string decodedString2 = decoder.DecodeString(new ArraySegment <byte>(encodedBytes)); Assert.IsTrue(ReferenceEquals(decodedString1, decodedString2)); }