< Summary

Line coverage
53%
Covered lines: 24
Uncovered lines: 21
Coverable lines: 45
Total lines: 92
Line coverage: 53.3%
Branch coverage
50%
Covered branches: 7
Total branches: 14
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)50%8863.63%
Dispose(...)75%4482.35%
DisposeAsync()0%220%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Net.Security/src/System/Net/Security/AuthenticatedStream.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.Tasks;
 6
 7namespace System.Net.Security
 8{
 9    // A public contract for a base abstract authenticated stream.
 10    public abstract class AuthenticatedStream : Stream
 11    {
 12        private readonly Stream _innerStream;
 13        private readonly bool _leaveStreamOpen;
 14
 3115        protected AuthenticatedStream(Stream innerStream, bool leaveInnerStreamOpen)
 3116        {
 3117            if (innerStream == null || innerStream == Stream.Null)
 018            {
 019                throw new ArgumentNullException(nameof(innerStream));
 20            }
 21
 3122            if (!innerStream.CanRead || !innerStream.CanWrite)
 023            {
 024                throw new ArgumentException(SR.net_io_must_be_rw_stream, nameof(innerStream));
 25            }
 26
 3127            _innerStream = innerStream;
 3128            _leaveStreamOpen = leaveInnerStreamOpen;
 3129        }
 30
 31        public bool LeaveInnerStreamOpen
 32        {
 33            get
 034            {
 035                return _leaveStreamOpen;
 036            }
 37        }
 38
 39        protected Stream InnerStream
 40        {
 41            get
 7642            {
 7643                return _innerStream;
 7644            }
 45        }
 46
 47        protected override void Dispose(bool disposing)
 3148        {
 49            try
 3150            {
 3151                if (disposing)
 3152                {
 3153                    if (_leaveStreamOpen)
 054                    {
 055                        _innerStream.Flush();
 056                    }
 57                    else
 3158                    {
 3159                        _innerStream.Dispose();
 3160                    }
 3161                }
 3162            }
 63            finally
 3164            {
 3165                base.Dispose(disposing);
 3166            }
 3167        }
 68
 69        public override ValueTask DisposeAsync()
 070        {
 71            try
 072            {
 073                ValueTask vt = _leaveStreamOpen ?
 074                    new ValueTask(_innerStream.FlushAsync()) :
 075                    _innerStream.DisposeAsync();
 076                GC.SuppressFinalize(this);
 077                return vt;
 78            }
 079            catch (Exception exc)
 080            {
 081                return ValueTask.FromException(exc);
 82            }
 083        }
 84
 85        public abstract bool IsAuthenticated { get; }
 86        public abstract bool IsMutuallyAuthenticated { get; }
 87        public abstract bool IsEncrypted { get; }
 88        public abstract bool IsSigned { get; }
 89        public abstract bool IsServer { get; }
 90    }
 91}
 92