public void T011_ThreadAddRemoveTest() { TestHelper.InMethod(); // Console.WriteLine("Beginning test {0}", MethodBase.GetCurrentMethod()); // This test adds and removes with mutiple threads, attempting to break the // uuid and localid dictionary coherence. EntityManager entman = new EntityManager(); SceneObjectGroup sog = NewSOG(); for (int j = 0; j < 20; j++) { List <Thread> trdlist = new List <Thread>(); for (int i = 0; i < 4; i++) { // Adds scene object NewTestThreads test = new NewTestThreads(entman, sog); Thread start = new Thread(new ThreadStart(test.TestAddSceneObject)); start.Start(); trdlist.Add(start); // Removes it test = new NewTestThreads(entman, sog); start = new Thread(new ThreadStart(test.TestRemoveSceneObject)); start.Start(); trdlist.Add(start); } foreach (Thread thread in trdlist) { thread.Join(); } if (entman.ContainsKey(sog.UUID) || entman.ContainsKey(sog.LocalId)) { found = (SceneObjectGroup)entman[sog.UUID]; Assert.That(found.UUID, Is.EqualTo(sog.UUID)); found = (SceneObjectGroup)entman[sog.LocalId]; Assert.That(found.UUID, Is.EqualTo(sog.UUID)); } } }
public void T011_ThreadAddRemoveTest() { TestHelpers.InMethod(); // This test adds and removes with mutiple threads, attempting to break the // uuid and localid dictionary coherence. EntityManager entman = new EntityManager(); SceneObjectGroup sog = NewSOG(); for (int j=0; j<20; j++) { List<Thread> trdlist = new List<Thread>(); for (int i=0; i<4; i++) { // Adds scene object NewTestThreads test = new NewTestThreads(entman,sog); Thread start = new Thread(new ThreadStart(test.TestAddSceneObject)); start.Start(); trdlist.Add(start); // Removes it test = new NewTestThreads(entman,sog); start = new Thread(new ThreadStart(test.TestRemoveSceneObject)); start.Start(); trdlist.Add(start); } foreach (Thread thread in trdlist) { thread.Join(); } if (entman.ContainsKey(sog.UUID) || entman.ContainsKey(sog.LocalId)) { found = (SceneObjectGroup)entman[sog.UUID]; Assert.That(found.UUID,Is.EqualTo(sog.UUID)); found = (SceneObjectGroup)entman[sog.LocalId]; Assert.That(found.UUID,Is.EqualTo(sog.UUID)); } } }