コード例 #1
0
        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);
            });
        }
コード例 #4
0
        public void GetInt_MinGreaterThanMaxEquals_Exception()
        {
            var target = new FastRandomRandomization();

            Assert.Catch <ArgumentOutOfRangeException>(() =>
            {
                target.GetInt(2, 1);
            }, "upperBound must be >=lowerBound");
        }
コード例 #5
0
        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);
 }