예제 #1
0
        public void AddOrUpdate_throws_after_close()
        {
            var set = new ConcurrentExpiringSet <string>();

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

            Assert.Throws <ObjectDisposedException>(() => set.AddOrUpdate("testKey2", DateTime.UtcNow - TimeSpan.FromSeconds(5)));
        }
        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.");
        }
        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.");
        }