public void ClearTransactionEventNotifiersTest( )
        {
            var testCache = new TestCache( );

            using (var scope = new TransactionScope(TransactionScopeOption.Required))
            {
                var cacheManager = new TransactionEventNotificationManager(testCache);

                // Add some items to the cache while inside a transaction
                testCache.AddItem("A");
                cacheManager.EnlistTransaction(Transaction.Current);

                testCache.AddItem("B");
                cacheManager.EnlistTransaction(Transaction.Current);

                testCache.AddItem("C");
                cacheManager.EnlistTransaction(Transaction.Current);

                // Clear the event notifiers
                cacheManager.ClearTransactionEventNotifiers( );

                // Commit the transaction
                // as the. As the event notifiers have been removed
                // the items will not be commited
                scope.Complete( );
            }

            Assert.IsFalse(testCache.Contains("A"));
            Assert.IsFalse(testCache.Contains("B"));
            Assert.IsFalse(testCache.Contains("C"));
        }
Esempio n. 2
0
        /// <summary>
        ///     Clears all entries from the cache.
        /// </summary>
        public void Clear( )
        {
            _privateCaches.Clear();

            _publicCache.Clear();

            _transactionEventNotificationManager.ClearTransactionEventNotifiers();
        }