public void GetLeafMessage() { MessageExpression me = new MessageExpression(); ParserContext pc = new ParserContext(ParserContext.DefaultBufferSize); FormatterContext fc = new FormatterContext(FormatterContext.DefaultBufferSize); // Passing null message (as parameter and in the contexts). try { me.GetLeafMessage(ref fc, null); Assert.Fail(); } catch (ExpressionEvaluationException) { } try { me.GetLeafMessage(ref pc, null); Assert.Fail(); } catch (ExpressionEvaluationException) { } Message msg = MessagesProvider.GetMessage(); Message anotherMsg = MessagesProvider.GetAnotherMessage(); Assert.IsTrue(me.GetLeafMessage(ref fc, msg) == msg); fc.CurrentMessage = anotherMsg; Assert.IsTrue(me.GetLeafMessage(ref fc, msg) == msg); Assert.IsTrue(me.GetLeafMessage(ref fc, null) == anotherMsg); Assert.IsTrue(me.GetLeafMessage(ref pc, msg) == msg); pc.CurrentMessage = anotherMsg; Assert.IsTrue(me.GetLeafMessage(ref pc, msg) == msg); Assert.IsTrue(me.GetLeafMessage(ref pc, null) == anotherMsg); }
public void InstantiationAndProperties() { FieldValueEqualsBinaryOperator ee = new FieldValueEqualsBinaryOperator(); Assert.IsNull(ee.ValueExpression); Assert.IsNull(ee.MessageExpression); BinaryConstantExpression bce = new BinaryConstantExpression("202030302020"); MessageExpression me = new MessageExpression(3); ee = new FieldValueEqualsBinaryOperator(me, bce); Assert.IsTrue(ee.ValueExpression == bce); Assert.IsTrue(ee.MessageExpression == me); ee.ValueExpression = null; ee.MessageExpression = null; Assert.IsNull(ee.ValueExpression); Assert.IsNull(ee.MessageExpression); try { ee.ValueExpression = new StringConstantExpression("Test"); Assert.Fail(); } catch (ArgumentException) { } }
/// <summary> /// Sends the specified linqExpression for execution. /// </summary> /// <param name="linqExpression">The linqExpression.</param> /// <param name="timeOut">The time out.</param> /// <param name="data">The data.</param> /// <returns></returns> /// <remarks>Your expression must return a type of object, or the JSON serializer may throw casting errors</remarks> public async Task <IReceivedMessage <object> > SendAsync(LinqExpressionToRun linqExpression, TimeSpan timeOut, IAdditionalMessageData data = null) { var message = new MessageExpression(MessageExpressionPayloads.FunctionText, _compositeSerialization.InternalSerializer.ConvertToBytes(linqExpression)); return(await _queue.SendAsync(message, timeOut, data).ConfigureAwait(false)); }
/// <inheritdoc /> public IQueueOutputMessage Send(LinqExpressionToRun linqExpression, IAdditionalMessageData data = null) { var message = new MessageExpression(MessageExpressionPayloads.ActionText, _compositeSerialization.InternalSerializer.ConvertToBytes(linqExpression)); return(_queue.Send(message, data)); }
/// <inheritdoc /> public async Task <IQueueOutputMessages> SendAsync(List <QueueMessage <LinqExpressionToRun, IAdditionalMessageData> > methods) { var messages = new List <QueueMessage <MessageExpression, IAdditionalMessageData> >(methods.Count); foreach (var method in methods) { var message = new MessageExpression(MessageExpressionPayloads.ActionText, _compositeSerialization.InternalSerializer.ConvertToBytes(method)); messages.Add(new QueueMessage <MessageExpression, IAdditionalMessageData>(message, method.MessageData)); } return(await _queue.SendAsync(messages).ConfigureAwait(false)); }
public void InstantiationAndProperties() { MessageExpression me = new MessageExpression(); Assert.IsTrue(me.FieldNumber == -1); me = new MessageExpression(11); Assert.IsTrue(me.FieldNumber == 11); me.FieldNumber = 5; Assert.IsTrue(me.FieldNumber == 5); }
public void GetLeafFieldNumber() { MessageExpression me = new MessageExpression(); Assert.IsTrue(me.GetLeafFieldNumber() == -1); me = new MessageExpression(11); Assert.IsTrue(me.GetLeafFieldNumber() == 11); me.FieldNumber = 5; Assert.IsTrue(me.GetLeafFieldNumber() == 5); }
/// <inheritdoc /> public async Task <IQueueOutputMessage> SendAsync(Expression <Action <IReceivedMessage <MessageExpression>, IWorkerNotification> > method, IAdditionalMessageData data = null, bool rawExpression = false) { if (rawExpression) { var message = new MessageExpression(MessageExpressionPayloads.ActionRaw, method); return(await _queue.SendAsync(message, data).ConfigureAwait(false)); } else { var message = new MessageExpression(MessageExpressionPayloads.Action, _serializer.ConvertMethodToBytes(method)); return(await _queue.SendAsync(message, data).ConfigureAwait(false)); } }
public void GetLeafFieldNumber() { MessageExpression me = new MessageExpression(4); SubMessageExpression sme = new SubMessageExpression(5, me); Assert.IsTrue(sme.GetLeafFieldNumber() == 4); me = new MessageExpression(11); sme.MessageExpression = me; Assert.IsTrue(sme.GetLeafFieldNumber() == 11); me.FieldNumber = 5; Assert.IsTrue(sme.GetLeafFieldNumber() == 5); }
public void GetLeafFieldNumber() { MessageExpression me = new MessageExpression(4); ParentMessageExpression pme = new ParentMessageExpression(me); Assert.IsTrue(pme.GetLeafFieldNumber() == 4); me = new MessageExpression(11); pme.MessageExpression = me; Assert.IsTrue(pme.GetLeafFieldNumber() == 11); me.FieldNumber = 5; Assert.IsTrue(pme.GetLeafFieldNumber() == 5); }
public void InstantiationAndProperties() { ParentMessageExpression pme = new ParentMessageExpression(); Assert.IsNull(pme.MessageExpression); MessageExpression me = new MessageExpression(); pme = new ParentMessageExpression(me); Assert.IsTrue(pme.MessageExpression == me); MessageExpression fve2 = new MessageExpression(); pme.MessageExpression = fve2; Assert.IsTrue(pme.MessageExpression == fve2); }
/// <inheritdoc /> public IQueueOutputMessages Send(List <QueueMessage <Expression <Action <IReceivedMessage <MessageExpression>, IWorkerNotification> >, IAdditionalMessageData> > methods, bool rawExpression = false) { var messages = new List <QueueMessage <MessageExpression, IAdditionalMessageData> >(methods.Count); foreach (var method in methods) { if (rawExpression) { var message = new MessageExpression(MessageExpressionPayloads.ActionRaw, method.Message); messages.Add(new QueueMessage <MessageExpression, IAdditionalMessageData>(message, method.MessageData)); } else { var message = new MessageExpression(MessageExpressionPayloads.Action, _serializer.ConvertMethodToBytes(method.Message)); messages.Add(new QueueMessage <MessageExpression, IAdditionalMessageData>(message, method.MessageData)); } } return(_queue.Send(messages)); }
public void InstantiationAndProperties() { IsSetExpression ee = new IsSetExpression(); Assert.IsNull(ee.MessageExpression); MessageExpression me = new MessageExpression(3); ee = new IsSetExpression(me); Assert.IsTrue(ee.MessageExpression.GetLeafFieldNumber() == 3); Assert.IsTrue(ee.MessageExpression == me); me.FieldNumber = 5; Assert.IsTrue(ee.MessageExpression.GetLeafFieldNumber() == 5); ee.MessageExpression = null; Assert.IsNull(ee.MessageExpression); }
public void InstantiationAndProperties() { MtiEqualsExpression ee = new MtiEqualsExpression(); Assert.IsTrue(ee.Mti == -1); Assert.IsNull(ee.MessageExpression); MessageExpression me = new MessageExpression(); ee = new MtiEqualsExpression(200, me); Assert.IsTrue(ee.Mti == 200); Assert.IsTrue(ee.MessageExpression == me); ee.Mti = 210; ee.MessageExpression = null; Assert.IsTrue(ee.Mti == 210); Assert.IsNull(ee.MessageExpression); }
public void GetLeafFieldValueBytes() { MessageExpression me = new MessageExpression(52); ParserContext pc = new ParserContext(ParserContext.DefaultBufferSize); FormatterContext fc = new FormatterContext(FormatterContext.DefaultBufferSize); // Passing null message (as parameter and in the contexts). try { me.GetLeafFieldValueBytes(ref fc, null); Assert.Fail(); } catch (ExpressionEvaluationException) { } try { me.GetLeafFieldValueBytes(ref pc, null); Assert.Fail(); } catch (ExpressionEvaluationException) { } Message msg = MessagesProvider.GetMessage(); Message anotherMsg = MessagesProvider.GetAnotherMessage(); Assert.IsTrue(MessagesProvider.CompareByteArrays(me.GetLeafFieldValueBytes(ref fc, msg), new byte[] { 0x15, 0x20, 0x25, 0x30, 0x35, 0x40, 0x45, 0x50 })); fc.CurrentMessage = anotherMsg; Assert.IsTrue(MessagesProvider.CompareByteArrays(me.GetLeafFieldValueBytes(ref fc, msg), new byte[] { 0x15, 0x20, 0x25, 0x30, 0x35, 0x40, 0x45, 0x50 })); Assert.IsTrue(MessagesProvider.CompareByteArrays(me.GetLeafFieldValueBytes(ref fc, null), new byte[] { 0x55, 0x60, 0x65, 0x70, 0x75, 0x80, 0x85, 0x90 })); Assert.IsTrue(MessagesProvider.CompareByteArrays(me.GetLeafFieldValueBytes(ref pc, msg), new byte[] { 0x15, 0x20, 0x25, 0x30, 0x35, 0x40, 0x45, 0x50 })); pc.CurrentMessage = anotherMsg; Assert.IsTrue(MessagesProvider.CompareByteArrays(me.GetLeafFieldValueBytes(ref pc, msg), new byte[] { 0x15, 0x20, 0x25, 0x30, 0x35, 0x40, 0x45, 0x50 })); Assert.IsTrue(MessagesProvider.CompareByteArrays(me.GetLeafFieldValueBytes(ref pc, null), new byte[] { 0x55, 0x60, 0x65, 0x70, 0x75, 0x80, 0x85, 0x90 })); }
public void InstantiationAndProperties() { SubMessageExpression sme = new SubMessageExpression(); Assert.IsTrue(sme.FieldNumber == -1); Assert.IsNull(sme.MessageExpression); MessageExpression me1 = new MessageExpression(); sme = new SubMessageExpression(5, me1); Assert.IsTrue(sme.FieldNumber == 5); Assert.IsTrue(sme.MessageExpression == me1); sme.FieldNumber = 9; Assert.IsTrue(sme.FieldNumber == 9); MessageExpression me2 = new MessageExpression(); sme.MessageExpression = me2; Assert.IsTrue(sme.MessageExpression == me2); }
/// <summary> /// Sends the specified linqExpression for execution. /// </summary> /// <param name="linqExpression">The linqExpression.</param> /// <param name="timeOut">The time out.</param> /// <param name="data">The data.</param> /// <returns></returns> /// <remarks>Your expression must return a type of object, or the JSON serializer may throw casting errors</remarks> public IReceivedMessage <object> Send(LinqExpressionToRun linqExpression, TimeSpan timeOut, IAdditionalMessageData data = null) { var message = new MessageExpression(MessageExpressionPayloads.FunctionText, _compositeSerialization.InternalSerializer.ConvertToBytes(linqExpression)); return(_queue.Send(message, timeOut, data)); }
/// <summary> /// Sends the specified linqExpression for execution. /// </summary> /// <param name="method">The linqExpression.</param> /// <param name="timeOut">The time out.</param> /// <param name="data">The data.</param> /// <returns></returns> /// <remarks> /// Your expression must return a type of object, or the JSON serializer may throw casting errors /// </remarks> public async Task <IReceivedMessage <object> > SendAsync(Expression <Func <IReceivedMessage <MessageExpression>, IWorkerNotification, object> > method, TimeSpan timeOut, IAdditionalMessageData data = null) { var message = new MessageExpression(MessageExpressionPayloads.Function, _serializer.ConvertFunctionToBytes(method)); return(await _queue.SendAsync(message, timeOut, data).ConfigureAwait(false)); }
/// <summary> /// Sends the specified linqExpression for execution. /// </summary> /// <param name="method">The linqExpression.</param> /// <param name="timeOut">The time out.</param> /// <param name="data">The data.</param> /// <returns></returns> /// <remarks> /// Your expression must return a type of object, or the JSON serializer may throw casting errors /// </remarks> public IReceivedMessage <object> Send(Expression <Func <IReceivedMessage <MessageExpression>, IWorkerNotification, object> > method, TimeSpan timeOut, IAdditionalMessageData data = null) { var message = new MessageExpression(MessageExpressionPayloads.Function, _serializer.ConvertFunctionToBytes(method)); return(_queue.Send(message, timeOut, data)); }
public void InstantiationAndProperties() { MidEqualsBinaryOperator ee = new MidEqualsBinaryOperator(); Assert.IsNull(ee.ValueExpression); Assert.IsNull(ee.MessageExpression); Assert.IsTrue(ee.StartIndex == 0); Assert.IsTrue(ee.Length == 0); BinaryConstantExpression bce = new BinaryConstantExpression("202030302020"); MessageExpression me = new MessageExpression(3); ee = new MidEqualsBinaryOperator(me, bce, 0, 3); Assert.IsTrue(ee.ValueExpression == bce); Assert.IsTrue(ee.MessageExpression == me); Assert.IsTrue(ee.StartIndex == 0); Assert.IsTrue(ee.Length == 3); ee.ValueExpression = null; ee.MessageExpression = null; ee.StartIndex = 1; ee.Length = 2; Assert.IsNull(ee.ValueExpression); Assert.IsNull(ee.MessageExpression); Assert.IsTrue(ee.StartIndex == 1); Assert.IsTrue(ee.Length == 2); try { ee.ValueExpression = new StringConstantExpression("Test"); Assert.Fail(); } catch (ArgumentException) { } try { ee = new MidEqualsBinaryOperator(me, bce, -1, 3); Assert.Fail(); } catch (ArgumentException) { } try { ee = new MidEqualsBinaryOperator(me, bce, 0, -1); Assert.Fail(); } catch (ArgumentException) { } try { ee.StartIndex = -1; Assert.Fail(); } catch (ArgumentException) { } try { ee.Length = -1; Assert.Fail(); } catch (ArgumentException) { } }
/// <inheritdoc /> public async Task <IQueueOutputMessage> SendAsync(LinqExpressionToRun linqExpression, IAdditionalMessageData data = null) { var message = new MessageExpression(MessageExpressionPayloads.ActionText, _compositeSerialization.InternalSerializer.ConvertToBytes(linqExpression)); return(await _queue.SendAsync(message, data).ConfigureAwait(false)); }