コード例 #1
0
        public void TestMappedStatementQueryWithThreadedReadWriteCache()
        {
            Hashtable results = new Hashtable();

            TestCacheThread.StartThread(dataMapper, results, "GetRWCachedAccountsViaResultMap");
            int firstId = (int)results["id"];

            TestCacheThread.StartThread(dataMapper, results, "GetRWCachedAccountsViaResultMap");
            int secondId = (int)results["id"];

            Assert.AreNotEqual(firstId, secondId);

            IList list = (IList)results["list"];

            Account account = (Account)list[1];

            account.EmailAddress = "*****@*****.**";
            dataMapper.Update("UpdateAccountViaInlineParameters", account);

            list = dataMapper.QueryForList("Account.GetCachedAccountsViaResultMap", null);

            int thirdId = HashCodeProvider.GetIdentityHashCode(list);

            Assert.AreNotEqual(firstId, thirdId);
        }
コード例 #2
0
ファイル: CacheTest.cs プロジェクト: jdd1990/IBatisNet_1.6.2
        public void TestMappedStatementQueryWithThreadedReadWriteNonSerializableCache()
        {
            Hashtable results = new Hashtable();

            // run a SELECT query from two different threads.  TestCacheThread.StartThread joins the
            // new thread to the current, so test execution does not continue until the new thread completes
            TestCacheThread.StartThread(sqlMap, results, "GetRWNSCachedAccountsViaResultMap");
            int firstId = (int)results["id"];

            TestCacheThread.StartThread(sqlMap, results, "GetRWNSCachedAccountsViaResultMap");
            int secondId = (int)results["id"];

            Assert.AreNotEqual(firstId, secondId);

            IList list = (IList)results["list"];

            Account account = (Account)list[1];

            account.EmailAddress = "*****@*****.**";
            sqlMap.Update("UpdateAccountViaInlineParameters", account);

            list = sqlMap.QueryForList("GetRWNSCachedAccountsViaResultMap", null);

            int thirdId = HashCodeProvider.GetIdentityHashCode(list);

            Assert.AreNotEqual(firstId, thirdId);
        }