func Test_Write_MsgContainer(t *testing.T) { expect := &mock.MsgContainer{[]mock.Message{ mock.Message{34, 3, 67, *(builtin.NewObject(&mock.SingleBuiltinInt32{45}))}, }} data := []byte{ 0xdc, 0xf8, 0xf1, 0x73, 0x1, 0x0, 0x0, 0x0, 0x22, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x43, 0x0, 0x0, 0x0, 0xee, 0x70, 0x1b, 0x1f, 0x2d, 0x0, 0x0, 0x0} utils.WriteCheck(t, data, expect.Box()) }
func Test_Processor_MessageContaitner(t *testing.T) { proc := mock.NewProcessorFactory( &TestHandler{}, bin.NewEncoderFactory(), bin.NewDecoderFactory(), dummy.NewInternalWaitress(time.Minute*5), tl.NewBaseIDBrokerFactory(0), ).GetProcessor(context.TODO(), 10) // Prepare request reqEncoder := bin.NewEncoder(new(bytes.Buffer)) conn, _ := uuid.NewV4() session, _ := uuid.NewV4() reqMsgId, _ := proc.NewMessageID(*session, time.Now(), 0) assert.NoError(t, (&mock.MsgContainer{ []mock.Message{ mock.Message{34, 3, 67, *(builtin.NewObject(&mock.FuncEmpty{}))}, }}).Box().Write(reqEncoder)) res := &testProcessorResult{} // fire err := proc.Process( tl.RequestContext{*conn, *session, reqMsgId, 2}, reqEncoder.Bytes(), res) assert.NoError(t, err) assert.Empty(t, res.responses, "responses should be empty") // Check requests // check result resResCtx, resMsgData := res.requests[0].RequestContext, res.requests[0].data assert.EqualValues(t, 3, resResCtx.SeqNo) assert.EqualValues(t, 34, 34) resBox := &builtin.ObjectBox{} assert.NoError(t, resBox.Read(bin.NewDecoder(bytes.NewBuffer(resMsgData)), proc, *session)) resBare, err := resBox.Bare() assert.NoError(t, err) assert.EqualValues(t, &mock.FuncEmpty{}, resBare) }