public void GenerateRuNumberTest() { for (var i = 0; i < 1000; i++) { var actual = carNumberGenerator.Generate(); Assert.IsNotNull(actual); Assert.AreEqual(true, !string.IsNullOrEmpty(actual)); Assert.AreEqual(true, Regex.IsMatch(actual, RuCarNumberPattern)); } }
public CarBase Generate() { var random = new Random(); var randModelType = random.Next(allModelTypes.Length); var carNumber = carNumberGenerator.Generate(); var randColor = RandomColor(); var randDateCreation = DateTimeExtensions.RandomDate(startDate); return(carFactory.Create(allModelTypes[randModelType], carNumber, randColor, State.AtHome, randDateCreation)); Color RandomColor() { var arrayOfColors = Enum.GetValues(typeof(Color)); return((Color)arrayOfColors.GetValue(random.Next(arrayOfColors.Length))); } }