public void RemoveInterceptrsTest() { ICollection <IInterceptor> types = new[] { new ListInterceptor() }; UniversalRandom.RemoveInterceptors(types); var item = _random.Randomize <int[]>(); Assert.IsNull(item); }
public void InterceptorsThreadSafe() { var hasExceptions = false; for (int i = 0; i < 5000; i++) { ThreadPool.QueueUserWorkItem(delegate { try { UniversalRandom.AddInterceptors(new List <IInterceptor> { new ArrayInterceptor() }); } catch (Exception) { hasExceptions = true; } }); ThreadPool.QueueUserWorkItem(delegate { try { UniversalRandom.RemoveInterceptors(new List <IInterceptor> { new ArrayInterceptor() }); } catch (Exception) { hasExceptions = true; } }); ThreadPool.QueueUserWorkItem(delegate { try { UniversalRandom.ClearInterceptors(); } catch (Exception) { hasExceptions = true; } }); } Thread.Sleep(2000); Assert.IsFalse(hasExceptions); }