< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Dispatcher.InputChannelBinder
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/InputChannelBinder.cs
Line coverage
35%
Covered lines: 12
Uncovered lines: 22
Coverable lines: 34
Total lines: 138
Line coverage: 35.2%
Branch coverage
25%
Covered branches: 1
Total branches: 4
Branch coverage: 25%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor()100%11100%
Init(...)50%2280%
Abort()100%110%
CloseAfterFault(...)100%110%
CreateRequestContext(...)100%110%
SendAsync(...)100%110%
RequestAsync(...)100%110%
WrapMessage(...)0%220%
SetNextDispatcher(...)100%11100%
DispatchAsync(...)100%11100%
DispatchAsync(...)100%110%
.ctor(...)100%110%
OnAbort()100%110%
OnCloseAsync(...)100%110%
OnReplyAsync(...)100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/InputChannelBinder.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.Threading;
 6using System.Threading.Tasks;
 7using CoreWCF.Channels;
 8using CoreWCF.Configuration;
 9using CoreWCF.Diagnostics;
 10using CoreWCF.Runtime;
 11
 12namespace CoreWCF.Dispatcher
 13{
 14    internal class InputChannelBinder : IChannelBinder
 15    {
 16        private IInputChannel _channel;
 17        private IServiceChannelDispatcher _next;
 18
 171819        public InputChannelBinder()
 20        {
 171821        }
 22
 23        internal void Init(IInputChannel channel, Uri listenUri)
 24        {
 171825            if (!((channel != null)))
 26            {
 27                Fx.Assert("InputChannelBinder.InputChannelBinder: (channel != null)");
 028                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(channel));
 29            }
 171830            _channel = channel;
 171831            ListenUri = listenUri;
 171832        }
 33
 34        public IChannel Channel
 35        {
 198936            get { return _channel; }
 37        }
 38
 39        public bool HasSession
 40        {
 353041            get { return _channel is ISessionChannel<IInputSession>; }
 42        }
 43
 171844        public Uri ListenUri { get; private set; }
 45
 46        public EndpointAddress LocalAddress
 47        {
 048            get { return _channel.LocalAddress; }
 49        }
 50
 51        public EndpointAddress RemoteAddress
 52        {
 53            get
 54            {
 055                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException());
 56            }
 57        }
 58
 59        public void Abort()
 60        {
 061            _channel.Abort();
 062        }
 63
 64        public void CloseAfterFault(TimeSpan timeout)
 65        {
 066            var helper = new TimeoutHelper(timeout);
 067            _channel.CloseAsync(helper.GetCancellationToken()).GetAwaiter().GetResult();
 068        }
 69
 70        public RequestContext CreateRequestContext(Message message)
 71        {
 072            return WrapMessage(message);
 73        }
 74
 75        public Task SendAsync(Message message, CancellationToken token)
 76        {
 077            throw TraceUtility.ThrowHelperError(new NotImplementedException(), message);
 78        }
 79
 80        public Task<Message> RequestAsync(Message message, CancellationToken token)
 81        {
 082            throw TraceUtility.ThrowHelperError(new NotImplementedException(), message);
 83        }
 84
 85        private RequestContext WrapMessage(Message message)
 86        {
 087            if (message == null)
 88            {
 089                return null;
 90            }
 91            else
 92            {
 093                return new InputRequestContext(message, this);
 94            }
 95        }
 96
 97        public void SetNextDispatcher(IServiceChannelDispatcher dispatcher)
 98        {
 171899            _next = dispatcher;
 1718100        }
 101
 102        public Task DispatchAsync(RequestContext context)
 103        {
 1718104            return _next.DispatchAsync(context);
 105        }
 106
 107        public Task DispatchAsync(Message message)
 108        {
 0109            RequestContext requestContext = WrapMessage(message);
 0110            return _next.DispatchAsync(requestContext);
 111        }
 112
 113        private class InputRequestContext : RequestContextBase
 114        {
 115            private readonly InputChannelBinder _binder;
 116
 117            internal InputRequestContext(Message request, InputChannelBinder binder)
 0118                : base(request, TimeSpan.Zero, TimeSpan.Zero)
 119            {
 0120                _binder = binder;
 0121            }
 122
 123            protected override void OnAbort()
 124            {
 0125            }
 126
 127            protected override Task OnCloseAsync(CancellationToken token)
 128            {
 0129                return Task.CompletedTask;
 130            }
 131
 132            protected override Task OnReplyAsync(Message message, CancellationToken token)
 133            {
 0134                return Task.CompletedTask;
 135            }
 136        }
 137    }
 138}