< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.DetectEofStream
Assembly: CoreWCF.Http
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Http/src/CoreWCF/Channels/DetectEofStream.cs
Line coverage
96%
Covered lines: 25
Uncovered lines: 1
Coverable lines: 26
Total lines: 71
Line coverage: 96.1%
Branch coverage
91%
Covered branches: 11
Total branches: 12
Branch coverage: 91.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%11100%
ReadAsync()75%4485.71%
ReadByte()100%22100%
Read(...)100%44100%
ReceivedEof()100%22100%
OnReceivedEof()100%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Http/src/CoreWCF/Channels/DetectEofStream.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.IO;
 5using System.Threading;
 6using System.Threading.Tasks;
 7
 8namespace CoreWCF.Channels
 9{
 10    internal abstract class DetectEofStream : DelegatingStream
 11    {
 12        protected DetectEofStream(Stream stream)
 62113            : base(stream)
 14        {
 62115            IsAtEof = false;
 62116        }
 17
 1867718        protected bool IsAtEof { get; private set; }
 19
 20        public override async Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationTo
 21        {
 649522            if (IsAtEof)
 23            {
 024                return 0;
 25            }
 649526            int returnValue = await base.ReadAsync(buffer, offset, count, cancellationToken);
 649527            if (returnValue == 0)
 28            {
 929                ReceivedEof();
 30            }
 649531            return returnValue;
 649532        }
 33
 34        public override int ReadByte()
 35        {
 1140636            int returnValue = base.ReadByte();
 1140637            if (returnValue == -1)
 38            {
 1739                ReceivedEof();
 40            }
 1140641            return returnValue;
 42        }
 43
 44        public override int Read(byte[] buffer, int offset, int count)
 45        {
 1151346            if (IsAtEof)
 47            {
 848                return 0;
 49            }
 1150550            int returnValue = base.Read(buffer, offset, count);
 1150551            if (returnValue == 0)
 52            {
 453                ReceivedEof();
 54            }
 1150555            return returnValue;
 56        }
 57
 58        private void ReceivedEof()
 59        {
 3060            if (!IsAtEof)
 61            {
 1862                IsAtEof = true;
 1863                OnReceivedEof();
 64            }
 3065        }
 66
 67        protected virtual void OnReceivedEof()
 68        {
 1869        }
 70    }
 71}