public void KeyRing_Prop()
        {
            // Arrange
            var keyRing = new Mock<IKeyRing>().Object;
            var cacheableKeyRing = new CacheableKeyRing(CancellationToken.None, DateTimeOffset.Now, keyRing);

            // Act & assert
            Assert.Same(keyRing, cacheableKeyRing.KeyRing);
        }
        public void IsValid_Expired_ReturnsFalse()
        {
            // Arrange
            var keyRing = new Mock<IKeyRing>().Object;
            DateTimeOffset now = DateTimeOffset.UtcNow;
            var cts = new CancellationTokenSource();
            var cacheableKeyRing = new CacheableKeyRing(cts.Token, now.AddHours(1), keyRing);

            // Act & assert
            Assert.True(CacheableKeyRing.IsValid(cacheableKeyRing, now.UtcDateTime));
            Assert.False(CacheableKeyRing.IsValid(cacheableKeyRing, now.AddHours(1).UtcDateTime));
        }
示例#3
0
 internal static bool IsValid(CacheableKeyRing keyRing, DateTime utcNow)
 {
     return(keyRing != null &&
            !keyRing._expirationToken.IsCancellationRequested &&
            keyRing.ExpirationTimeUtc > utcNow);
 }
 internal static bool IsValid(CacheableKeyRing keyRing, DateTime utcNow)
 {
     return keyRing != null
         && !keyRing._expirationToken.IsCancellationRequested
         && keyRing.ExpirationTimeUtc > utcNow;
 }