public void Committed_invalidate_sets_collected_during_transaction()
        {
            var mockCache = new Mock<ICache>();
            var transactionHandler = new CacheTransactionHandler(mockCache.Object);

            var transaction = Mock.Of<DbTransaction>();
            transactionHandler.InvalidateSets(transaction, new[] {"ES1", "ES2"});
            transactionHandler.InvalidateSets(transaction, new[] {"ES3", "ES2"});

            transactionHandler.Committed(transaction, Mock.Of<DbTransactionInterceptionContext>());

            mockCache.Verify(c =>c.InvalidateSets(new[] {"ES1", "ES2", "ES3"}), Times.Once());
        }
Ejemplo n.º 2
0
        public void Committed_invalidate_sets_collected_during_transaction()
        {
            var mockCache          = new Mock <ICache>();
            var transactionHandler = new CacheTransactionHandler(mockCache.Object);

            var transaction = Mock.Of <DbTransaction>();

            transactionHandler.InvalidateSets(transaction, new[] { "ES1", "ES2" }, Mock.Of <DbConnection>());
            transactionHandler.InvalidateSets(transaction, new[] { "ES3", "ES2" }, Mock.Of <DbConnection>());

            transactionHandler.Committed(transaction, Mock.Of <DbTransactionInterceptionContext>());

            mockCache.Verify(c => c.InvalidateSets(new[] { "ES1", "ES2", "ES3" }), Times.Once());
        }
        public void RolledBack_clears_affected_sets_collected_during_transaction()
        {
            var mockCache          = new Mock <ICache>();
            var transactionHandler = new CacheTransactionHandler(mockCache.Object);

            var transaction = Mock.Of <DbTransaction>();

            transactionHandler.InvalidateSets(transaction, new[] { "ES1", "ES2" }, null);
            transactionHandler.InvalidateSets(transaction, new[] { "ES3", "ES2" }, null);

            transactionHandler.RolledBack(transaction, Mock.Of <DbTransactionInterceptionContext>());
            transactionHandler.Committed(transaction, Mock.Of <DbTransactionInterceptionContext>());

            mockCache.Verify(c => c.InvalidateSets(It.IsAny <IEnumerable <string> >(), null), Times.Never());
        }
        public void RolledBack_clears_affected_sets_collected_during_transaction()
        {
            var mockCache = new Mock<ICache>();
            var transactionHandler = new CacheTransactionHandler(mockCache.Object);

            var transaction = Mock.Of<DbTransaction>();
            transactionHandler.InvalidateSets(transaction, new[] { "ES1", "ES2" });
            transactionHandler.InvalidateSets(transaction, new[] { "ES3", "ES2" });

            transactionHandler.RolledBack(transaction, Mock.Of<DbTransactionInterceptionContext>());
            transactionHandler.Committed(transaction, Mock.Of<DbTransactionInterceptionContext>());

            mockCache.Verify(c => c.InvalidateSets(It.IsAny<IEnumerable<string>>()), Times.Never());
        }