< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Runtime.Ticks
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/Common/src/CoreWCF/Runtime/Ticks.cs
Line coverage
71%
Covered lines: 10
Uncovered lines: 4
Coverable lines: 14
Total lines: 59
Line coverage: 71.4%
Branch coverage
68%
Covered branches: 11
Total branches: 16
Branch coverage: 68.7%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
FromMilliseconds(...)100%11100%
ToMilliseconds(...)100%110%
FromTimeSpan(...)100%11100%
ToTimeSpan(...)100%11100%
Add(...)68.75%161666.66%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/Common/src/CoreWCF/Runtime/Ticks.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;
 5
 6namespace CoreWCF.Runtime
 7{
 8    internal static class Ticks
 9    {
 10        public static long Now
 11        {
 12            get
 13            {
 130014                return DateTime.UtcNow.Ticks;
 15            }
 16        }
 17
 18        public static long FromMilliseconds(int milliseconds)
 19        {
 158920            return checked((long)milliseconds * TimeSpan.TicksPerMillisecond);
 21        }
 22
 23        public static int ToMilliseconds(long ticks)
 24        {
 025            return checked((int)(ticks / TimeSpan.TicksPerMillisecond));
 26        }
 27
 28        public static long FromTimeSpan(TimeSpan duration)
 29        {
 34830            return duration.Ticks;
 31        }
 32
 33        public static TimeSpan ToTimeSpan(long ticks)
 34        {
 9435            return new TimeSpan(ticks);
 36        }
 37
 38        public static long Add(long firstTicks, long secondTicks)
 39        {
 90240            if (firstTicks == long.MaxValue || firstTicks == long.MinValue)
 41            {
 042                return firstTicks;
 43            }
 90244            if (secondTicks == long.MaxValue || secondTicks == long.MinValue)
 45            {
 146                return secondTicks;
 47            }
 90148            if (firstTicks >= 0 && long.MaxValue - firstTicks <= secondTicks)
 49            {
 050                return long.MaxValue - 1;
 51            }
 90152            if (firstTicks <= 0 && long.MinValue - firstTicks >= secondTicks)
 53            {
 054                return long.MinValue + 1;
 55            }
 90156            return checked(firstTicks + secondTicks);
 57        }
 58    }
 59}