public static void TestBin(Packet obj) { object originalData = obj.Data; Encoder.Encode(obj, new Parser.Encoder.CallbackImp((encodedPackets) => { var decoder = new Parser.Decoder(); decoder.On(Parser.Decoder.EVENT_DECODED, new ListenerImpl((args) => { var packet = (Packet)args; obj.Data = originalData; obj.Attachments = -1; AssertPacket(obj, packet); })); foreach (var packet in encodedPackets) { if (packet is string) { decoder.Add((string)packet); } else if (packet is byte[]) { decoder.Add((byte[])packet); } } })); }
public void Decode() { var decoder = new Parser.Decoder(); var called = false; decoder.On(Parser.Decoder.EVENT_DECODED, new ListenerImpl((data1) => { called = true; })); decoder.Add("0/woot"); Assert.True(called); }
public static void Test(Packet obj) { Encoder.Encode(obj, new Parser.Encoder.CallbackImp((encodedPackets) => { var decoder = new Parser.Decoder(); decoder.On(Parser.Decoder.EVENT_DECODED, new ListenerImpl((data1) => { var packet = (Packet)data1; AssertPacket(obj, packet); })); decoder.Add((string)encodedPackets[0]); })); }