public void Contains_returns_true_for_valid_entry()
        {
            var set = new ConcurrentExpiringSet <string>();

            set.AddOrUpdate("testKey", DateTime.UtcNow + TimeSpan.FromSeconds(5));
            Assert.True(set.Contains("testKey"), "The set should return true for a valid entry.");
        }
        public void Contains_returns_false_for_expired_entry()
        {
            var set = new ConcurrentExpiringSet <string>();

            set.AddOrUpdate("testKey", DateTime.UtcNow - TimeSpan.FromSeconds(5));
            Assert.False(set.Contains("testKey"), "The set should return false for an expired entry.");
        }
Esempio n. 3
0
        public void Contains_throws_after_close()
        {
            var set = new ConcurrentExpiringSet <string>();

            set.AddOrUpdate("testKey", DateTime.UtcNow + TimeSpan.FromSeconds(5));
            set.Close();

            Assert.Throws <ObjectDisposedException>(() => set.Contains("testKey"));
        }