public void CanCreateCacheItemPolicyWithAbsoluteExpirationByDateTimeFromDotNetConfigFile(string cacheItemPolicyName, DateTime expectedExpires, bool cacheItemPolicyShouldBeNull)
        {
            // Arrange
            var expected = new DateTimeOffset(expectedExpires);
            var config = new ConfigFileBasedCacheItemPolicyConfiguration();
            var factory = new CacheItemPolicyFactory(config);

            // Act
            var cacheItemPolicy = factory.Create(cacheItemPolicyName);

            // Assert
            if (cacheItemPolicyShouldBeNull)
            {
                cacheItemPolicy.ShouldBeNull();
                return;
            }

            cacheItemPolicy.AbsoluteExpiration.ShouldEqual(expected);
            cacheItemPolicy.SlidingExpiration.ShouldEqual(ObjectCache.NoSlidingExpiration);
        }
        public void CanCreateCacheItemPolicyWithAbsoluteExpirationByTimeSpanFromDotNetConfigFile(string cacheItemPolicyName, TimeSpan expectedExpires, bool cacheItemPolicyShouldBeNull)
        {
            // Arrange
            var currentDateTimeUtc = new DateTime(2073, 09, 15, 11, 32, 27);

            var expected =
                (expectedExpires == TimeSpan.MaxValue)
                    ? ObjectCache.InfiniteAbsoluteExpiration
                    : new DateTimeOffset(currentDateTimeUtc.Add(expectedExpires));

            var config = new ConfigFileBasedCacheItemPolicyConfiguration();
            var factory = new CacheItemPolicyFactory(config);
            MockCacheItemPolicyDateTimeProvider.Instance.SetUtcNow(currentDateTimeUtc);
            MockCacheItemPolicyDateTimeProvider.Install();
            try
            {
                // Act
                var cacheItemPolicy = factory.Create(cacheItemPolicyName);

                // Assert
                if (cacheItemPolicyShouldBeNull)
                {
                    cacheItemPolicy.ShouldBeNull();
                    return;
                }

                cacheItemPolicy.AbsoluteExpiration.ShouldEqual(expected);
                cacheItemPolicy.SlidingExpiration.ShouldEqual(ObjectCache.NoSlidingExpiration);
            }
            finally
            {
                MockCacheItemPolicyDateTimeProvider.Uninstall();
            }
        }