public void TestEncode() { TextLineEncoder encoder = new TextLineEncoder(Encoding.UTF8, LineDelimiter.Windows); ProtocolCodecSession session = new ProtocolCodecSession(); IProtocolEncoderOutput output = session.EncoderOutput; encoder.Encode(session, "ABC", output); Assert.AreEqual(1, session.EncoderOutputQueue.Count); IoBuffer buf = (IoBuffer)session.EncoderOutputQueue.Dequeue(); Assert.AreEqual(5, buf.Remaining); Assert.AreEqual((Byte)'A', buf.Get()); Assert.AreEqual((Byte)'B', buf.Get()); Assert.AreEqual((Byte)'C', buf.Get()); Assert.AreEqual((Byte)'\r', buf.Get()); Assert.AreEqual((Byte)'\n', buf.Get()); }
public void TestEncode() { TextLineEncoder encoder = new TextLineEncoder(Encoding.UTF8, LineDelimiter.Windows); ProtocolCodecSession session = new ProtocolCodecSession(); IProtocolEncoderOutput output = session.EncoderOutput; encoder.Encode(session, "ABC", output); Assert.AreEqual(1, session.EncoderOutputQueue.Count); IoBuffer buf = (IoBuffer)session.EncoderOutputQueue.Dequeue(); Assert.AreEqual(5, buf.Remaining); Assert.AreEqual((Byte)'A', buf.Get()); Assert.AreEqual((Byte)'B', buf.Get()); Assert.AreEqual((Byte)'C', buf.Get()); Assert.AreEqual((Byte)'\r', buf.Get()); Assert.AreEqual((Byte)'\n', buf.Get()); }
/// <summary> /// Instantiates. /// </summary> /// <param name="encoding">the <see cref="Encoding"/></param> /// <param name="encodingDelimiter">the encoding <see cref="LineDelimiter"/></param> /// <param name="decodingDelimiter">the decoding <see cref="LineDelimiter"/></param> public TextLineCodecFactory(Encoding encoding, LineDelimiter encodingDelimiter, LineDelimiter decodingDelimiter) { _encoder = new TextLineEncoder(encoding, encodingDelimiter); _decoder = new TextLineDecoder(encoding, decodingDelimiter); }
/// <summary> /// Instantiates. /// </summary> /// <param name="encoding">the <see cref="Encoding"/></param> /// <param name="encodingDelimiter">the encoding <see cref="LineDelimiter"/></param> /// <param name="decodingDelimiter">the decoding <see cref="LineDelimiter"/></param> public TextLineCodecFactory(Encoding encoding, LineDelimiter encodingDelimiter, LineDelimiter decodingDelimiter) { _encoder = new TextLineEncoder(encoding, encodingDelimiter); _decoder = new TextLineDecoder(encoding, decodingDelimiter); }