< Summary

Class:Microsoft.Azure.ServiceBus.Amqp.AmqpResponseMessage
Assembly:Microsoft.Azure.ServiceBus
File(s):C:\Git\azure-sdk-for-net\sdk\servicebus\Microsoft.Azure.ServiceBus\src\Amqp\AmqpResponseMessage.cs
Covered lines:0
Uncovered lines:28
Coverable lines:28
Total lines:90
Line coverage:0% (0 of 28)
Covered branches:0
Total branches:14
Branch coverage:0% (0 of 14)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
get_AmqpMessage()-0%100%
get_StatusCode()-0%100%
get_TrackingId()-0%100%
get_Map()-0%100%
CreateResponse(...)-0%100%
GetValue(...)-0%0%
GetListValue(...)-0%0%
GetResponseErrorCondition()-0%0%
ToMessagingContractException()-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\servicebus\Microsoft.Azure.ServiceBus\src\Amqp\AmqpResponseMessage.cs

#LineLine coverage
 1// Copyright (c) Microsoft. All rights reserved.
 2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
 3
 4namespace Microsoft.Azure.ServiceBus.Amqp
 5{
 6    using System;
 7    using System.Collections.Generic;
 8    using System.Linq;
 9    using Azure.Amqp;
 10    using Azure.Amqp.Encoding;
 11    using Azure.Amqp.Framing;
 12
 13    internal sealed class AmqpResponseMessage
 14    {
 15        readonly AmqpMessage responseMessage;
 16
 017        AmqpResponseMessage(AmqpMessage responseMessage)
 18        {
 019            this.responseMessage = responseMessage;
 020            this.StatusCode = this.responseMessage.GetResponseStatusCode();
 021            if (this.responseMessage.ApplicationProperties.Map.TryGetValue<string>(ManagementConstants.Properties.Tracki
 22            {
 023                this.TrackingId = trackingId;
 24            }
 25
 026            if (responseMessage.ValueBody != null)
 27            {
 028                this.Map = responseMessage.ValueBody.Value as AmqpMap;
 29            }
 030        }
 31
 032        public AmqpMessage AmqpMessage => this.responseMessage;
 33
 034        public AmqpResponseStatusCode StatusCode { get; }
 35
 036        public string TrackingId { get; }
 37
 038        public AmqpMap Map { get; }
 39
 40        public static AmqpResponseMessage CreateResponse(AmqpMessage response)
 41        {
 042            return new AmqpResponseMessage(response);
 43        }
 44
 45        public TValue GetValue<TValue>(MapKey key)
 46        {
 047            if (this.Map == null)
 48            {
 049                throw new ArgumentException(AmqpValue.Name);
 50            }
 51
 052            var valueObject = this.Map[key];
 053            if (valueObject == null)
 54            {
 055                throw new ArgumentException(key.ToString());
 56            }
 57
 058            if (!(valueObject is TValue))
 59            {
 060                throw new ArgumentException(key.ToString());
 61            }
 62
 063            return (TValue)this.Map[key];
 64        }
 65
 66        public IEnumerable<TValue> GetListValue<TValue>(MapKey key)
 67        {
 068            if (this.Map == null)
 69            {
 070                throw new ArgumentException(AmqpValue.Name);
 71            }
 72
 073            var list = (List<object>)this.Map[key];
 74
 075            return list.Cast<TValue>();
 76        }
 77
 78        public AmqpSymbol GetResponseErrorCondition()
 79        {
 080            var condition = this.responseMessage.ApplicationProperties.Map[ManagementConstants.Response.ErrorCondition];
 81
 082            return condition is AmqpSymbol amqpSymbol ? amqpSymbol : null;
 83        }
 84
 85        public Exception ToMessagingContractException()
 86        {
 087            return this.responseMessage.ToMessagingContractException(this.StatusCode);
 88        }
 89    }
 90}