< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.ContentOnlyMessage
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Channels/ContentOnlyMessage.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 14
Coverable lines: 14
Total lines: 101
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

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

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/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.Xml;
 5using CoreWCF.Diagnostics;
 6
 7namespace CoreWCF.Channels
 8{
 9    /// <summary>
 10    /// Base class for non-SOAP messages
 11    /// </summary>
 12    internal abstract class ContentOnlyMessage : Message
 13    {
 14        private readonly MessageHeaders _headers;
 15        private MessageProperties _properties;
 16
 017        protected ContentOnlyMessage()
 18        {
 019            _headers = new MessageHeaders(MessageVersion.None);
 020        }
 21
 22        public override MessageHeaders Headers
 23        {
 24            get
 25            {
 026                if (IsDisposed)
 27                {
 028                    throw TraceUtility.ThrowHelperError(CreateMessageDisposedException(), this);
 29                }
 30
 031                return _headers;
 32            }
 33        }
 34
 35        public override MessageProperties Properties
 36        {
 37            get
 38            {
 039                if (IsDisposed)
 40                {
 041                    throw TraceUtility.ThrowHelperError(CreateMessageDisposedException(), this);
 42                }
 43
 044                if (_properties == null)
 45                {
 046                    _properties = new MessageProperties();
 47                }
 48
 049                return _properties;
 50            }
 51        }
 52
 53        public override MessageVersion Version
 54        {
 55            get
 56            {
 057                return _headers.MessageVersion;
 58            }
 59        }
 60
 61        protected override void OnBodyToString(XmlDictionaryWriter writer)
 62        {
 063            OnWriteBodyContents(writer);
 064        }
 65    }
 66
 67    internal class StringMessage : ContentOnlyMessage
 68    {
 69        private readonly string _data;
 70
 71        public StringMessage(string data)
 72            : base()
 73        {
 74            _data = data;
 75        }
 76
 77        public override bool IsEmpty
 78        {
 79            get
 80            {
 81                return string.IsNullOrEmpty(_data);
 82            }
 83        }
 84
 85        protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
 86        {
 87            if (_data != null && _data.Length > 0)
 88            {
 89                writer.WriteElementString("BODY", _data);
 90            }
 91        }
 92    }
 93
 94    internal class NullMessage : StringMessage
 95    {
 96        public NullMessage()
 97            : base(string.Empty)
 98        {
 99        }
 100    }
 101}