< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Runtime.Ticks
Assembly: CoreWCF.WebHttp
File(s): /home/runner/work/CoreWCF/CoreWCF/src/Common/src/CoreWCF/Runtime/Ticks.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 14
Coverable lines: 14
Total lines: 59
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 16
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
FromMilliseconds(...)100%110%
ToMilliseconds(...)100%110%
FromTimeSpan(...)100%110%
ToTimeSpan(...)100%110%
Add(...)0%16160%

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            {
 014                return DateTime.UtcNow.Ticks;
 15            }
 16        }
 17
 18        public static long FromMilliseconds(int milliseconds)
 19        {
 020            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        {
 030            return duration.Ticks;
 31        }
 32
 33        public static TimeSpan ToTimeSpan(long ticks)
 34        {
 035            return new TimeSpan(ticks);
 36        }
 37
 38        public static long Add(long firstTicks, long secondTicks)
 39        {
 040            if (firstTicks == long.MaxValue || firstTicks == long.MinValue)
 41            {
 042                return firstTicks;
 43            }
 044            if (secondTicks == long.MaxValue || secondTicks == long.MinValue)
 45            {
 046                return secondTicks;
 47            }
 048            if (firstTicks >= 0 && long.MaxValue - firstTicks <= secondTicks)
 49            {
 050                return long.MaxValue - 1;
 51            }
 052            if (firstTicks <= 0 && long.MinValue - firstTicks >= secondTicks)
 53            {
 054                return long.MinValue + 1;
 55            }
 056            return checked(firstTicks + secondTicks);
 57        }
 58    }
 59}