コード例 #1
0
        public void RemoveInterceptrsTest()
        {
            ICollection <IInterceptor> types = new[] { new ListInterceptor() };

            UniversalRandom.RemoveInterceptors(types);
            var item = _random.Randomize <int[]>();

            Assert.IsNull(item);
        }
コード例 #2
0
        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);
        }