< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.NullMessage
Assembly: CoreWCF.Http
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Http/src/CoreWCF/Channels/ContentOnlyMessage.cs
Line coverage
100%
Covered lines: 2
Uncovered lines: 0
Coverable lines: 2
Total lines: 109
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor()100%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Http/src/CoreWCF/Channels/ContentOnlyMessage.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 System.Xml;
 6using CoreWCF.Diagnostics;
 7
 8// TODO: This is duplicated from Primitives. Either move to common code and include in both places or add to contract. I
 9
 10namespace CoreWCF.Channels
 11{
 12    /// <summary>
 13    /// Base class for non-SOAP messages
 14    /// </summary>
 15    internal abstract class ContentOnlyMessage : Message
 16    {
 17        private readonly MessageHeaders _headers;
 18        private MessageProperties _properties;
 19
 20        protected ContentOnlyMessage()
 21        {
 22            _headers = new MessageHeaders(MessageVersion.None);
 23        }
 24
 25        public override MessageHeaders Headers
 26        {
 27            get
 28            {
 29                if (IsDisposed)
 30                {
 31                    throw TraceUtility.ThrowHelperError(CreateMessageDisposedException(), this);
 32                }
 33
 34                return _headers;
 35            }
 36        }
 37
 38        public override MessageProperties Properties
 39        {
 40            get
 41            {
 42                if (IsDisposed)
 43                {
 44                    throw TraceUtility.ThrowHelperError(CreateMessageDisposedException(), this);
 45                }
 46
 47                if (_properties == null)
 48                {
 49                    _properties = new MessageProperties();
 50                }
 51
 52                return _properties;
 53            }
 54        }
 55
 56        public override MessageVersion Version
 57        {
 58            get
 59            {
 60                return _headers.MessageVersion;
 61            }
 62        }
 63
 64        protected override void OnBodyToString(XmlDictionaryWriter writer)
 65        {
 66            OnWriteBodyContents(writer);
 67        }
 68
 69        internal Exception CreateMessageDisposedException()
 70        {
 71            return new ObjectDisposedException("", SR.MessageClosed);
 72        }
 73    }
 74
 75    internal class StringMessage : ContentOnlyMessage
 76    {
 77        private readonly string _data;
 78
 79        public StringMessage(string data)
 80            : base()
 81        {
 82            _data = data;
 83        }
 84
 85        public override bool IsEmpty
 86        {
 87            get
 88            {
 89                return string.IsNullOrEmpty(_data);
 90            }
 91        }
 92
 93        protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
 94        {
 95            if (_data != null && _data.Length > 0)
 96            {
 97                writer.WriteElementString("BODY", _data);
 98            }
 99        }
 100    }
 101
 102    internal class NullMessage : StringMessage
 103    {
 104        public NullMessage()
 135105            : base(string.Empty)
 106        {
 135107        }
 108    }
 109}

Methods/Properties

.ctor()