Пример #1
0
        public void ExpireEventDoesntFireForDifferentKey()
        {
            const string key         = "expectedKey";
            var          dep         = new EventWaitHandleCacheDependency(key);
            var          expireFired = false;

            dep.OnExpireItem += (x, y) => expireFired = true;
            EventWaitHandleCacheDependency.SignalExpiration("differentKey");

            Thread.Sleep(100);
            Assert.IsFalse(expireFired);
        }
Пример #2
0
        public void ExpireEventFiresForMatchedKey()
        {
            const string key        = "expectedKey";
            var          dep        = new EventWaitHandleCacheDependency(key);
            var          expiredKey = "";

            dep.OnExpireItem += (x, y) => expiredKey = y.Key;

            dep.WaitForReady();
            EventWaitHandleCacheDependency.SignalExpiration(key);
            Thread.Sleep(100);
            Assert.AreEqual(key, expiredKey);
        }