public void GetByteValuesUniqueValuesOnly() { var generator = new MockRandomNumberGeneratorForGetByteValues(ValueGeneration.UniqueValuesOnly); using (var random = new SecureRandom(generator)) { var elements = random.GetByteValues( 10, ValueGeneration.UniqueValuesOnly); Assert.AreEqual(10, elements.Length); for (var i = 0; i < elements.Length; i++) { var element = elements[i]; Assert.IsTrue(element >= byte.MinValue); Assert.IsTrue(element <= byte.MaxValue); } Assert.AreEqual(elements.Length, new HashSet<byte>(elements).Count); Assert.AreEqual(11, generator.MethodCallCount); } }
public void GetByteValuesDuplicatesAllowed() { var generator = new MockRandomNumberGeneratorForGetByteValues(ValueGeneration.DuplicatesAllowed); using (var random = new SecureRandom(generator)) { var elements = random.GetByteValues(10, ValueGeneration.DuplicatesAllowed); { Assert.AreEqual(10, elements.Length); for (var i = 0; i < elements.Length; i++) { var element = elements[i]; Assert.IsTrue(element >= byte.MinValue); Assert.IsTrue(element <= byte.MaxValue); } Assert.AreEqual(1, generator.MethodCallCount); } } }