public void Can_Decode_And_Assign_NullableInt_Without_Boxing_Using_Generic_DecodeObject() { // write to buffer var buffer = new ByteBuffer(1024, true); int value = randNum.Next(0, 1000); Encoder.WriteInt(buffer, value, false); // compile lambda expression var compiled = CompileGenericPropertyDecodeExpression(typeof(TestCompositeClass), "NullableIntValue"); // execute var instance = new TestCompositeClass(); var formatCode = AmqpCodec.DecodeFormatCode(buffer); compiled(instance, buffer, formatCode); Assert.AreEqual(value, instance.NullableIntValue); }
public void Can_Decode_And_Assign_NullableInt_Without_Boxing_Using_Generic_DecodeObject() { // write to buffer var buffer = new ByteBuffer(1024, true); int value = randNum.Next(0, 1000); Encoder.WriteInt(buffer, value, false); // compile lambda expression var compiled = CompileGenericPropertyDecodeExpression(typeof(TestCompositeClass), "NullableIntValue"); // execute var instance = new TestCompositeClass(); var formatCode = AmqpCodec.DecodeFormatCode(buffer); compiled(instance, buffer, formatCode); Assert.AreEqual(value, instance.NullableIntValue); }
public void Can_Encode_Int_Without_Boxing_Using_Generic_DecodeObject() { var buffer = new ByteBuffer(1024, true); var instance = new TestCompositeClass(); instance.IntValue = randNum.Next(300, 1000); // compile lambda expression var compiled = CompileGenericPropertyEncodeExpression(typeof(TestCompositeClass), "IntValue"); // execute compiled(instance, buffer); // assert var formatCode = AmqpBitConverter.ReadByte(buffer); Assert.AreEqual(FormatCode.Int, formatCode); var value = AmqpBitConverter.ReadInt(buffer); Assert.AreEqual(instance.IntValue, value); }
public void Can_Encode_Int_Without_Boxing_Using_Generic_DecodeObject() { var buffer = new ByteBuffer(1024, true); var instance = new TestCompositeClass(); instance.IntValue = randNum.Next(300, 1000); // compile lambda expression var compiled = CompileGenericPropertyEncodeExpression(typeof(TestCompositeClass), "IntValue"); // execute compiled(instance, buffer); // assert var formatCode = AmqpBitConverter.ReadByte(buffer); Assert.AreEqual(FormatCode.Int, formatCode); var value = AmqpBitConverter.ReadInt(buffer); Assert.AreEqual(instance.IntValue, value); }