| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Collections.Generic; |
| | 6 | | using System.ComponentModel; |
| | 7 | | using Azure.Core; |
| | 8 | |
|
| | 9 | | namespace Azure.Messaging.ServiceBus |
| | 10 | | { |
| | 11 | | /// <summary> |
| | 12 | | /// This class contains methods to create certain ServiceBus models. |
| | 13 | | /// </summary> |
| | 14 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 15 | | public static class ServiceBusModelFactory |
| | 16 | | { |
| | 17 | | /// <summary> |
| | 18 | | /// Creates a new ServiceBusReceivedMessage instance for mocking. |
| | 19 | | /// </summary> |
| | 20 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 21 | | public static ServiceBusReceivedMessage ServiceBusReceivedMessage( |
| | 22 | | BinaryData body = default, |
| | 23 | | string messageId = default, |
| | 24 | | string partitionKey = default, |
| | 25 | | string viaPartitionKey = default, |
| | 26 | | string sessionId = default, |
| | 27 | | string replyToSessionId = default, |
| | 28 | | TimeSpan timeToLive = default, |
| | 29 | | string correlationId = default, |
| | 30 | | string label = default, |
| | 31 | | string to = default, |
| | 32 | | string contentType = default, |
| | 33 | | string replyTo = default, |
| | 34 | | DateTimeOffset scheduledEnqueueTime = default, |
| | 35 | | IDictionary<string, object> properties = default, |
| | 36 | | Guid lockTokenGuid = default, |
| | 37 | | int deliveryCount = default, |
| | 38 | | DateTimeOffset lockedUntil = default, |
| | 39 | | long sequenceNumber = -1, |
| | 40 | | string deadLetterSource = default, |
| | 41 | | long enqueuedSequenceNumber = default, |
| | 42 | | DateTimeOffset enqueuedTime = default) |
| | 43 | | { |
| 4 | 44 | | var sentMessage = new ServiceBusMessage |
| 4 | 45 | | { |
| 4 | 46 | | Body = body, |
| 4 | 47 | | CorrelationId = correlationId, |
| 4 | 48 | | Label = label, |
| 4 | 49 | | To = to, |
| 4 | 50 | | ContentType = contentType, |
| 4 | 51 | | ReplyTo = replyTo, |
| 4 | 52 | | ScheduledEnqueueTime = scheduledEnqueueTime |
| 4 | 53 | | }; |
| 4 | 54 | | if (messageId != default) |
| | 55 | | { |
| 2 | 56 | | sentMessage.MessageId = messageId; |
| | 57 | | } |
| 4 | 58 | | if (partitionKey != default) |
| | 59 | | { |
| 2 | 60 | | sentMessage.PartitionKey = partitionKey; |
| | 61 | | } |
| 4 | 62 | | if (viaPartitionKey != default) |
| | 63 | | { |
| 2 | 64 | | sentMessage.ViaPartitionKey = viaPartitionKey; |
| | 65 | | } |
| 4 | 66 | | if (sessionId != default) |
| | 67 | | { |
| 2 | 68 | | sentMessage.SessionId = sessionId; |
| | 69 | | } |
| 4 | 70 | | if (replyToSessionId != default) |
| | 71 | | { |
| 2 | 72 | | sentMessage.ReplyToSessionId = replyToSessionId; |
| | 73 | | } |
| 4 | 74 | | if (timeToLive != default) |
| | 75 | | { |
| 2 | 76 | | sentMessage.TimeToLive = timeToLive; |
| | 77 | | } |
| 4 | 78 | | if (properties != default) |
| | 79 | | { |
| 2 | 80 | | sentMessage.Properties = properties; |
| | 81 | | } |
| | 82 | |
|
| 4 | 83 | | return new ServiceBusReceivedMessage |
| 4 | 84 | | { |
| 4 | 85 | | SentMessage = sentMessage, |
| 4 | 86 | | LockTokenGuid = lockTokenGuid, |
| 4 | 87 | | DeliveryCount = deliveryCount, |
| 4 | 88 | | LockedUntil = lockedUntil, |
| 4 | 89 | | SequenceNumber = sequenceNumber, |
| 4 | 90 | | DeadLetterSource = deadLetterSource, |
| 4 | 91 | | EnqueuedSequenceNumber = enqueuedSequenceNumber, |
| 4 | 92 | | EnqueuedTime = enqueuedTime |
| 4 | 93 | | }; |
| | 94 | | } |
| | 95 | | } |
| | 96 | | } |