< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.IdentityModel.Protocols.WSTrust.Lifetime
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/WSTrust/Lifetime.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 10
Coverable lines: 10
Total lines: 52
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%110%
.ctor(...)0%660%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/WSTrust/Lifetime.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.IdentityModel.Protocols.WSTrust
 7{
 8    /// <summary>
 9    /// Used in the RequestSecurityToken or RequestSecurityTokenResponse to indicated the desired or
 10    /// required lifetime of a token. Everything here is stored in Utc format.
 11    /// </summary>
 12    public class Lifetime
 13    {
 14        /// <summary>
 15        /// Instantiates a LifeTime object with token creation and expiration time in Utc.
 16        /// </summary>
 17        /// <param name="created">Token creation time in Utc.</param>
 18        /// <param name="expires">Token expiration time in Utc.</param>
 19        /// <exception cref="ArgumentException">When the given expiration time is
 20        /// before the given creation time.</exception>
 21        public Lifetime(DateTime created, DateTime expires)
 022            : this((DateTime?)created, (DateTime?)expires)
 23        {
 024        }
 25
 26        /// <summary>
 27        /// Instantiates a LifeTime object with token creation and expiration time in Utc.
 28        /// </summary>
 29        /// <param name="created">Token creation time in Utc.</param>
 30        /// <param name="expires">Token expiration time in Utc.</param>
 31        /// <exception cref="ArgumentException">When the given expiration time is
 32        /// before the given creation time.</exception>
 033        public Lifetime(DateTime? created, DateTime? expires)
 34        {
 035            if (created != null && expires != null && expires.Value <= created.Value)
 036                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.ID2000)));
 37
 038            Created = DateTimeUtil.ToUniversalTime(created);
 039            Expires = DateTimeUtil.ToUniversalTime(expires);
 040        }
 41
 42        /// <summary>
 43        /// Gets the token creation time in UTC time.
 44        /// </summary>
 045        public DateTime? Created { get; set; }
 46
 47        /// <summary>
 48        /// Gets the token expiration time in UTC time.
 49        /// </summary>
 050        public DateTime? Expires { get; set; }
 51    }
 52}