< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Description.MessageDescriptionItems
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Description/MessageDescription.cs
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 177
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Description/MessageDescription.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System;
 5using CoreWCF.Channels;
 6
 7namespace CoreWCF.Description
 8{
 9    public class MessageDescription
 10    {
 11        private static Type s_typeOfUntypedMessage;
 12        private MessageDescriptionItems _items;
 13
 14        //XmlQualifiedName xsdType;
 15
 16        public MessageDescription(string action, MessageDirection direction) : this(action, direction, null) { }
 17
 18        internal MessageDescription(string action, MessageDirection direction, MessageDescriptionItems items)
 19        {
 20            if (!MessageDirectionHelper.IsDefined(direction))
 21            {
 22                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(directi
 23            }
 24
 25            Action = action;
 26            Direction = direction;
 27            _items = items;
 28        }
 29
 30        internal MessageDescription(MessageDescription other)
 31        {
 32            Action = other.Action;
 33            Direction = other.Direction;
 34            Items.Body = other.Items.Body.Clone();
 35            foreach (MessageHeaderDescription mhd in other.Items.Headers)
 36            {
 37                Items.Headers.Add(mhd.Clone() as MessageHeaderDescription);
 38            }
 39            foreach (MessagePropertyDescription mpd in other.Items.Properties)
 40            {
 41                Items.Properties.Add(mpd.Clone() as MessagePropertyDescription);
 42            }
 43            MessageName = other.MessageName;
 44            MessageType = other.MessageType;
 45        }
 46
 47        public MessageDescription Clone()
 48        {
 49            return new MessageDescription(this);
 50        }
 51
 52        public string Action { get; internal set; }
 53
 54        public MessageBodyDescription Body
 55        {
 56            get { return Items.Body; }
 57        }
 58
 59        public MessageDirection Direction { get; }
 60
 61        public MessageHeaderDescriptionCollection Headers
 62        {
 63            get { return Items.Headers; }
 64        }
 65
 66        public MessagePropertyDescriptionCollection Properties
 67        {
 68            get { return Items.Properties; }
 69        }
 70
 71        internal MessageDescriptionItems Items
 72        {
 73            get
 74            {
 75                if (_items == null)
 76                {
 77                    _items = new MessageDescriptionItems();
 78                }
 79
 80                return _items;
 81            }
 82        }
 83
 84        internal bool HasProtectionLevel => false;
 85
 86        internal static Type TypeOfUntypedMessage
 87        {
 88            get
 89            {
 90                if (s_typeOfUntypedMessage == null)
 91                {
 92                    s_typeOfUntypedMessage = typeof(Message);
 93                }
 94                return s_typeOfUntypedMessage;
 95            }
 96        }
 97
 98        internal XmlName MessageName { get; set; }
 99
 100        public Type MessageType { get; set; }
 101
 102        internal bool IsTypedMessage
 103        {
 104            get
 105            {
 106                return MessageType != null;
 107            }
 108        }
 109
 110        internal bool IsUntypedMessage
 111        {
 112            get
 113            {
 114                return (Body.ReturnValue != null && Body.Parts.Count == 0 && Body.ReturnValue.Type == TypeOfUntypedMessa
 115                     (Body.ReturnValue == null && Body.Parts.Count == 1 && Body.Parts[0].Type == TypeOfUntypedMessage);
 116            }
 117        }
 118
 119        internal bool IsVoid
 120        {
 121            get
 122            {
 123                return !IsTypedMessage && Body.Parts.Count == 0 && (Body.ReturnValue == null || Body.ReturnValue.Type ==
 124            }
 125        }
 126    }
 127
 128    internal class MessageDescriptionItems
 129    {
 130        private MessageHeaderDescriptionCollection _headers;
 131        private MessageBodyDescription _body;
 132        private MessagePropertyDescriptionCollection _properties;
 133
 134        internal MessageBodyDescription Body
 135        {
 136            get
 137            {
 172907138                if (_body == null)
 139                {
 5018140                    _body = new MessageBodyDescription();
 141                }
 142
 172907143                return _body;
 144            }
 145            set
 146            {
 80147                _body = value;
 80148            }
 149        }
 150
 151        internal MessageHeaderDescriptionCollection Headers
 152        {
 153            get
 154            {
 15830155                if (_headers == null)
 156                {
 5018157                    _headers = new MessageHeaderDescriptionCollection();
 158                }
 159
 15830160                return _headers;
 161            }
 162        }
 163
 164        internal MessagePropertyDescriptionCollection Properties
 165        {
 166            get
 167            {
 5569168                if (_properties == null)
 169                {
 4489170                    _properties = new MessagePropertyDescriptionCollection();
 171                }
 172
 5569173                return _properties;
 174            }
 175        }
 176    }
 177}