public void Create_Default() { var id = Substitute.For<IMessage>(); var message = new AdditionalMessageData(); var test = new SendMessageCommand(id, message); Assert.Equal(id, test.MessageToSend); Assert.Equal(message, test.MessageData); }
public static TimeSpan GetExpiration(SendMessageCommand commandSend, IHeaders headers) { //there are three possible locations for a message expiration. The user data and the header / internal headers //grab it from the internal header var expiration = commandSend.MessageToSend.GetInternalHeader(headers.StandardHeaders.RpcTimeout).Timeout; //if the header value is zero, check the message expiration if (expiration == TimeSpan.Zero) { //try the message header expiration = commandSend.MessageToSend.GetHeader(headers.StandardHeaders.RpcTimeout).Timeout; } //if the header value is zero, check the message expiration if (expiration == TimeSpan.Zero && commandSend.MessageData.GetExpiration().HasValue) { // ReSharper disable once PossibleInvalidOperationException expiration = commandSend.MessageData.GetExpiration().Value; } return expiration; }
internal static SQLiteCommand GetMainCommand(SendMessageCommand commandSend, SQLiteConnection connection, SqLiteCommandStringCache commandCache, IHeaders headers, ICompositeSerialization serializer) { var command = connection.CreateCommand(); command.CommandText = commandCache.GetCommand(SqLiteCommandStringTypes.InsertMessageBody); var serialization = serializer.Serializer.MessageToBytes(new MessageBody { Body = commandSend.MessageToSend.Body }); command.Parameters.Add("@body", DbType.Binary, -1); command.Parameters["@body"].Value = serialization.Output; commandSend.MessageToSend.SetHeader(headers.StandardHeaders.MessageInterceptorGraph, serialization.Graph); command.Parameters.Add("@headers", DbType.Binary, -1); command.Parameters["@headers"].Value = serializer.InternalSerializer.ConvertToBytes(commandSend.MessageToSend.Headers); return command; }