public void GetUniqueInts_RangeLowerThanLength_Exception()
        {
            var target = new BasicRandomization();

            Assert.Catch <ArgumentOutOfRangeException>(() =>
            {
                target.GetUniqueInts(5, 0, 4);
            }, "The length is 5, but the possible unique values between 0 (inclusive) and 4 (exclusive) are 4.");
        }
Esempio n. 2
0
        public void GetUniqueInts_RangeLowerThanLength_Exception()
        {
            var target = new BasicRandomization();

            ExceptionAssert.IsThrowing(new ArgumentOutOfRangeException("length", "The length is 5, but the possible unique values between 0 (inclusive) and 4 (exclusive) are 4."), () =>
            {
                target.GetUniqueInts(5, 0, 4);
            });
        }
        public void GetUniqueInts_Length_ArrayWithUniqueInts()
        {
            var target = new BasicRandomization();
            var actual = target.GetUniqueInts(10, 0, 10);

            Assert.AreEqual(10, actual.Length);
            Assert.AreEqual(10, actual.Distinct().Count());

            for (int i = 0; i < 10; i++)
            {
                Assert.IsTrue(actual[i] >= 0 && actual[i] < 10);
            }

            actual = target.GetUniqueInts(10, 10, 20);
            Assert.AreEqual(10, actual.Length);
            Assert.AreEqual(10, actual.Distinct().Count());

            for (int i = 0; i < 10; i++)
            {
                Assert.IsTrue(actual[i] >= 10 && actual[i] < 20);
            }

            actual = target.GetUniqueInts(2, 0, 20);
            Assert.AreEqual(2, actual.Length);
            Assert.AreEqual(2, actual.Distinct().Count());

            for (int i = 0; i < 2; i++)
            {
                Assert.IsTrue(actual[i] >= 0 && actual[i] < 20);
            }

            FlowAssert.IsAtLeastOneAttemptOk(100, () =>
            {
                actual = target.GetUniqueInts(2, 0, 20);
                Assert.AreEqual(2, actual.Length);
                Assert.AreEqual(2, actual.Distinct().Count());

                Assert.IsTrue(actual[0] >= 2);
            });
        }
        public void GetUniqueInts()
        {
            var target = new BasicRandomization();

            target.GetUniqueInts(50, 0, 100);
        }
Esempio n. 5
0
 public void Basic_GetUniqueInts()
 {
     _basic.GetUniqueInts(_arrayLength, _min, _max);
 }