public void RemoveRandomizersTest() { ICollection <Type> types = new[] { typeof(int) }; UniversalRandom.RemoveRandomizers(types); var item1 = _random.Randomize <int>(); var item2 = _random.Randomize <int>(); Assert.AreEqual(item1, item2); Assert.AreEqual(item1, 0); }
public void RandomizersThreadSafe() { var hasExceptions = false; for (int i = 0; i < 5000; i++) { ThreadPool.QueueUserWorkItem(delegate { try { UniversalRandom.AddRandomizers( new Dictionary <Type, IRandomizeble> { { typeof(int), new Int32Random() } }); } catch (Exception) { hasExceptions = true; } }); ThreadPool.QueueUserWorkItem(delegate { try { UniversalRandom.RemoveRandomizers(new List <Type> { typeof(int) }); } catch (Exception) { hasExceptions = true; } }); ThreadPool.QueueUserWorkItem(delegate { try { UniversalRandom.ClearRandomizers(); } catch (Exception) { hasExceptions = true; } }); } Thread.Sleep(2000); Assert.IsFalse(hasExceptions); }