public void MultiThreaded_ConcurrencyExceptionOnAdd() { ConcurrencyTester tester1 = new ConcurrencyTester(odDictionaryStringString, 0); ConcurrencyTester tester2 = new ConcurrencyTester(odDictionaryStringString, 20000); Thread thread1 = new Thread(new ThreadStart(tester1.AddItems)); Thread thread2 = new Thread(new ThreadStart(tester2.AddItems)); thread1.Start(); thread2.Start(); thread1.Join(); thread2.Join(); Assert.IsTrue(ExceptionThrown.Thrown, "Testing concurrency is dicey without modifying base code to add delays, if this test fails, try running it again."); }
public void MultiThreaded_ConcurrencyExceptionOnRemove() { // some starting data for (int i = 0; i < 40000; i++) { odDictionaryStringString.Add("Key" + i, "Value" + i); } ConcurrencyTester tester1 = new ConcurrencyTester(odDictionaryStringString, 0); ConcurrencyTester tester2 = new ConcurrencyTester(odDictionaryStringString, 20000); Thread thread1 = new Thread(new ThreadStart(tester1.RemoveItems)); Thread thread2 = new Thread(new ThreadStart(tester2.RemoveItems)); thread1.Start(); thread2.Start(); thread1.Join(); thread2.Join(); Assert.IsTrue(ExceptionThrown.Thrown, "Testing concurrency is dicey without modifying base code to add delays, if this test fails, try running it again."); }