public void IntegerValuesShouldBeReturnedInCycle(int length) { // Arrange var random = new DeterministicRandom(length); // Act var cycle1 = Enumerable.Range(1, length).Select(i => random.NextInt()).ToArray(); var cycle2 = Enumerable.Range(1, length).Select(i => random.NextInt()).ToArray(); var cycle3 = Enumerable.Range(1, length).Select(i => random.NextInt()).ToArray(); // Assert CollectionAssert.AreEqual(cycle1, cycle2); CollectionAssert.AreEqual(cycle2, cycle3); }
/// <remarks> /// This method relies on a feature of <see cref="JContainerGenerator"/> that /// the keys of properties are only non-negative numbers, chosen /// sequentially from 0 and not exceeding 9. /// </remarks> private string AddWildcards(string path) { var indexesToChange = new List <int>(); for (var i = 0; i < path.Length; ++i) { var c = path[i]; if (char.IsDigit(c)) { var useWildcard = random.NextInt() % 5 == 0; // 20% chance if (useWildcard) { indexesToChange.Add(i); } } } var builder = new StringBuilder(path); foreach (var index in indexesToChange) { builder[index] = '*'; } return(builder.ToString()); }
public static void Shuffle <T>(this IList <T> list, DeterministicRandom random) { var elementsCount = list.Count; Shuffle(list, () => random.NextInt() % elementsCount); }
public void IntegerValuesShouldBeReturnedInCycle(int length) { // Arrange var random = new DeterministicRandom(length); // Act var cycle1 = Enumerable.Range(1, length).Select(i => random.NextInt()).ToArray(); var cycle2 = Enumerable.Range(1, length).Select(i => random.NextInt()).ToArray(); var cycle3 = Enumerable.Range(1, length).Select(i => random.NextInt()).ToArray(); // Assert CollectionAssert.AreEqual(cycle1, cycle2); CollectionAssert.AreEqual(cycle2, cycle3); }