public void GetUniqueInts_RangeLowerThanLength_Exception() { var target = new FastRandomRandomization(); 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."); }
public void GetUniqueInts_Length_ArrayWithUniqueInts() { var target = new FastRandomRandomization(); 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 FastRandom_GetUniqueInts() { _fastRandom.GetUniqueInts(_arrayLength, _min, _max); }