public void GetInt_NegativeValues_Negative()
        {
            var target = new FastRandomRandomization();

            var actual = target.GetInt(-10, -9);

            Assert.AreEqual(-10, actual);
        }
Пример #2
0
        public void GetInt_Range_RandomInRangeResult()
        {
            var target = new FastRandomRandomization();

            FlowAssert.IsAtLeastOneAttemptOk(100, () => {
                Assert.AreEqual(0, target.GetInt(0, 2));
            });

            FlowAssert.IsAtLeastOneAttemptOk(100, () => {
                Assert.AreEqual(1, target.GetInt(0, 2));
            });

            for (int i = 0; i < 100; i++)
            {
                Assert.AreNotEqual(2, target.GetInt(0, 2));
            }
        }
Пример #3
0
        public void GetInt_MinGreaterThanMaxEquals_Exception()
        {
            var target = new FastRandomRandomization();

            ExceptionAssert.IsThrowing(new ArgumentOutOfRangeException("upperBound", 1, "upperBound must be >=lowerBound"), () => {
                target.GetInt(2, 1);
            });
        }
        public void GetInt_MinGreaterThanMaxEquals_Exception()
        {
            var target = new FastRandomRandomization();

            Assert.Catch <ArgumentOutOfRangeException>(() =>
            {
                target.GetInt(2, 1);
            }, "upperBound must be >=lowerBound");
        }
        public void GetDouble_ManyThreads_DiffRandomResult()
        {
            var target = new FastRandomRandomization();
            var actual = new BlockingCollection <int>();

            Parallel.For(0, 1000, (i) =>
            {
                actual.Add(target.GetInt(0, int.MaxValue));
            });

            Assert.AreEqual(1000, actual.Count);
            Assert.AreEqual(1000, actual.Distinct().Count());
        }
Пример #6
0
 public void FastRandom_GetInt()
 {
     _fastRandom.GetInt(_min, _max);
 }