public static void Cleanup()
        {
            var randomizersList = new Dictionary <Type, IRandomizeble>();

            randomizersList[typeof(decimal)]  = new DecimalRandom();
            randomizersList[typeof(string)]   = new StringRandom();
            randomizersList[typeof(char)]     = new CharRandom();
            randomizersList[typeof(int)]      = new Int32Random();
            randomizersList[typeof(long)]     = new Int64Random();
            randomizersList[typeof(bool)]     = new BoolRandom();
            randomizersList[typeof(byte)]     = new ByteRandom();
            randomizersList[typeof(sbyte)]    = new SByteRandom();
            randomizersList[typeof(float)]    = new FloatRandom();
            randomizersList[typeof(double)]   = new DoubleRandom();
            randomizersList[typeof(short)]    = new Int16Random();
            randomizersList[typeof(uint)]     = new UInt32Random();
            randomizersList[typeof(ushort)]   = new UInt16Random();
            randomizersList[typeof(ulong)]    = new UInt64Random();
            randomizersList[typeof(DateTime)] = new DateTimeRandom();
            UniversalRandom.AddRandomizers(randomizersList);

            UniversalRandom.AddInterceptors(new List <IInterceptor>
            {
                new ListInterceptor(),
                new EnumInterceptor(),
                new ArrayInterceptor()
            });
        }
        public void AddInterceptorsTest()
        {
            var interceptors = new List <IInterceptor> {
                new FakeInterceptor()
            };

            UniversalRandom.AddInterceptors(interceptors);
            var item1 = _random.Randomize <int>();
            var item2 = _random.Randomize <int>();

            Assert.AreEqual(item1, item2);
            Assert.AreEqual(item1, FakeInterceptor.Fake);
        }
        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);
        }