< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Configuration.TimeSpanOrInfiniteConverter
Assembly: CoreWCF.ConfigurationManager
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.ConfigurationManager/src/CoreWCF/Configuration/TimeSpanOrInfiniteConverter.cs
Line coverage
20%
Covered lines: 1
Uncovered lines: 4
Coverable lines: 5
Total lines: 26
Line coverage: 20%
Branch coverage
16%
Covered branches: 1
Total branches: 6
Branch coverage: 16.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
ConvertTo(...)0%440%
ConvertFrom(...)50%22100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.ConfigurationManager/src/CoreWCF/Configuration/TimeSpanOrInfiniteConverter.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.ComponentModel;
 6using System.Globalization;
 7
 8namespace CoreWCF.Configuration
 9{
 10    internal class TimeSpanOrInfiniteConverter : TimeSpanConverter
 11    {
 12        public override object ConvertTo(ITypeDescriptorContext ctx, CultureInfo ci, object value, Type type)
 13        {
 014            if (!(value is TimeSpan timeSpan))
 015                throw new ArgumentException(SR.Format(SR.ConfigInvalidClassFactoryValue, value.GetType().Name,
 016                    type.Name));
 17
 018            return timeSpan == TimeSpan.MaxValue ? "Infinite" : base.ConvertTo(ctx, ci, timeSpan, type);
 19        }
 20
 21        public override object ConvertFrom(ITypeDescriptorContext ctx, CultureInfo ci, object data)
 22        {
 2423            return (string)data == "Infinite" ? TimeSpan.MaxValue : base.ConvertFrom(ctx, ci, data);
 24        }
 25    }
 26}