< Summary

Class:Azure.Messaging.ServiceBus.ServiceBusModelFactory
Assembly:Azure.Messaging.ServiceBus
File(s):C:\Git\azure-sdk-for-net\sdk\servicebus\Azure.Messaging.ServiceBus\src\Primitives\ServiceBusModelFactory.cs
Covered lines:35
Uncovered lines:0
Coverable lines:35
Total lines:96
Line coverage:100% (35 of 35)
Covered branches:14
Total branches:14
Branch coverage:100% (14 of 14)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
ServiceBusReceivedMessage(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\servicebus\Azure.Messaging.ServiceBus\src\Primitives\ServiceBusModelFactory.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Collections.Generic;
 6using System.ComponentModel;
 7using Azure.Core;
 8
 9namespace 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        {
 444            var sentMessage = new ServiceBusMessage
 445            {
 446                Body = body,
 447                CorrelationId = correlationId,
 448                Label = label,
 449                To = to,
 450                ContentType = contentType,
 451                ReplyTo = replyTo,
 452                ScheduledEnqueueTime = scheduledEnqueueTime
 453            };
 454            if (messageId != default)
 55            {
 256                sentMessage.MessageId = messageId;
 57            }
 458            if (partitionKey != default)
 59            {
 260                sentMessage.PartitionKey = partitionKey;
 61            }
 462            if (viaPartitionKey != default)
 63            {
 264                sentMessage.ViaPartitionKey = viaPartitionKey;
 65            }
 466            if (sessionId != default)
 67            {
 268                sentMessage.SessionId = sessionId;
 69            }
 470            if (replyToSessionId != default)
 71            {
 272                sentMessage.ReplyToSessionId = replyToSessionId;
 73            }
 474            if (timeToLive != default)
 75            {
 276                sentMessage.TimeToLive = timeToLive;
 77            }
 478            if (properties != default)
 79            {
 280                sentMessage.Properties = properties;
 81            }
 82
 483            return new ServiceBusReceivedMessage
 484            {
 485                SentMessage = sentMessage,
 486                LockTokenGuid = lockTokenGuid,
 487                DeliveryCount = deliveryCount,
 488                LockedUntil = lockedUntil,
 489                SequenceNumber = sequenceNumber,
 490                DeadLetterSource = deadLetterSource,
 491                EnqueuedSequenceNumber = enqueuedSequenceNumber,
 492                EnqueuedTime = enqueuedTime
 493            };
 94        }
 95    }
 96}

Methods/Properties

ServiceBusReceivedMessage(...)