public void ShardedCacheTransactionHandler_ShouldThrowIfDictionaryEmpty()
        {
            const string dbName = "some-other-database";

            var dbConnectionMock = new Mock <DbConnection>();

            dbConnectionMock.Setup(conn => conn.Database).Returns(dbName);

            var shardDictionary = new Lazy <Dictionary <string, ICache> >();

            var handler = new ShardedCacheTransactionHandlerTester(shardDictionary);

            handler.TestCacheResolver(dbConnectionMock.Object);
        }
        public void ShardedCacheTransactionHandler_ShouldResolveICache()
        {
            const string dbName           = "some-database";
            var          applicationCache = new NullCache();

            var dbConnectionMock = new Mock <DbConnection>();

            dbConnectionMock.Setup(conn => conn.Database).Returns(dbName);

            var shardDictionary = new Lazy <Dictionary <string, ICache> >();

            shardDictionary.Value[dbName] = applicationCache;

            var handler        = new ShardedCacheTransactionHandlerTester(shardDictionary);
            var someOtherCache = new NullCache();
            var resolvedCache  = handler.TestCacheResolver(dbConnectionMock.Object);

            Assert.AreSame(resolvedCache, applicationCache);
            Assert.AreNotSame(resolvedCache, someOtherCache);
        }