Пример #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
        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);
        }
Пример #3
0
            public static void StartThread(IDataMapper dataMapper, Hashtable results, string statementName)
            {
                TestCacheThread tct    = new TestCacheThread(dataMapper, results, statementName);
                Thread          thread = new Thread(new ThreadStart(tct.Run));

                thread.Start();
                try
                {
                    thread.Join();
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
Пример #4
0
 public static void StartThread(IDataMapper dataMapper, Hashtable results, string statementName) 
 {
     TestCacheThread tct = new TestCacheThread(dataMapper, results, statementName);
     Thread thread = new Thread( new ThreadStart(tct.Run) );
     thread.Start();
     try 
     {
         thread.Join();
     } 
     catch (Exception e) 
     {
         throw e;
     }
 }