public void RandomizersAreUnique() { int[] values = new int[10]; for (int i = 0; i < 10; i++) { values[i] = Randomizer.CreateRandomizer().Next(); } Assert.That(values, Is.Unique); }
public void CanGetArrayOfRandomInts() { Randomizer r = Randomizer.CreateRandomizer(); int[] ints = r.GetInts(1, 100, 10); Assert.That(ints.Length, Is.EqualTo(10)); foreach (int i in ints) { Assert.That(i, Is.InRange(1, 100)); } }
public void CanGetArrayOfRandomEnums() { Randomizer r = Randomizer.CreateRandomizer(); object[] enums = r.GetEnums(10, typeof(AttributeTargets)); Assert.That(enums.Length, Is.EqualTo(10)); foreach (object e in enums) { Assert.That(e, Is.TypeOf(typeof(AttributeTargets))); } }
public void RandomDoublesAreUnique() { Randomizer r = Randomizer.CreateRandomizer(); double[] values = new double[10]; for (int i = 0; i < 10; i++) { values[i] = r.NextDouble(); } Assert.That(values, Is.Unique); }
public void CanGetArrayOfRandomDoubles() { Randomizer r = Randomizer.CreateRandomizer(); double[] doubles = r.GetDoubles(0.5, 1.5, 10); Assert.That(doubles.Length, Is.EqualTo(10)); foreach (double d in doubles) { Assert.That(d, Is.InRange(0.5, 1.5)); } // Heuristic: Could fail occasionally Assert.That(doubles, Is.Unique); }