public IEnumerable <IEnumerable <int> > Generate(int numberOfLevels, int maxNumber, bool subsequentOddEven) { var result = new List <List <int> >(); var oddEven = subsequentOddEven ? (_randomiser.RandomNextBool() ? Randomiser.OddEven.Even : Randomiser.OddEven.Odd) : Randomiser.OddEven.Any; for (int i = 0; i < numberOfLevels; i++) { var row = new List <int>(); for (int j = 0; j <= i; j++) { var value = _randomiser.RandomNextInt(maxNumber, oddEven); row.Add(value); } result.Add(row); oddEven = _randomiser.SwitchOddEven(oddEven); } return(result); }
public void RandomNextBoolReturnsExpectedValues() { var watchdog = 10000; var wasTrue = false; var wasFalse = false; while (wasFalse == false && wasTrue == false && watchdog > 0) { var result = _sut.RandomNextBool(); if (result) { wasTrue = true; } else { wasFalse = true; } watchdog--; } Assert.True(watchdog > 0); }