示例#1
0
        public void Should_return_configured_timespan()
        {
            TimeSpan ttl = TimeSpan.FromSeconds(30);

            RelativeTtl ttlStrategy = new RelativeTtl(ttl);

            Ttl retrieved = ttlStrategy.GetTtl(new Context("someExecutionKey"), null);

            retrieved.Timespan.Should().BeCloseTo(ttl);
            retrieved.SlidingExpiration.Should().BeFalse();
        }
示例#2
0
        public void Should_return_configured_timespan_from_time_requested()
        {
            DateTimeOffset fixedTime = SystemClock.DateTimeOffsetUtcNow();
            TimeSpan       ttl       = TimeSpan.FromSeconds(30);
            TimeSpan       delay     = TimeSpan.FromSeconds(5);

            RelativeTtl ttlStrategy = new RelativeTtl(ttl);

            SystemClock.DateTimeOffsetUtcNow = () => fixedTime.Add(delay);

            Ttl retrieved = ttlStrategy.GetTtl(new Context("someExecutionKey"), null);

            retrieved.Timespan.Should().BeCloseTo(ttl);
            retrieved.SlidingExpiration.Should().BeFalse();
        }