public void RandomString_GivenMaxLength_ReturnsRandomStringWithAlternatingLowerCharNumberUpperCharNumber() { var safeRandomizerService = new SafeRandomizerService(); var randomString = safeRandomizerService.RandomString(10); Match match = Regex.Match(randomString, @"[a-z][0-9][A-Z][0-9][a-z][0-9][A-Z][0-9][a-z][0-9]", RegexOptions.Singleline); Assert.True(match.Success, "Random string should return string alternating between lower char, number, upper char and then number again"); }
public void Next_GivenMixedMinMax_ReturnsValueBetweenMinMax() { var min = -15; var max = 5; var safeRandomizerService = new SafeRandomizerService(); var randomResult = safeRandomizerService.Next(min, max); Assert.InRange(randomResult, min, max); }
public void Next_GivenGreaterMinThanMax_ReturnsArgumentOutOfRange() { var min = 10; var max = 5; var safeRandomizerService = new SafeRandomizerService(); Exception testException = null; try { var randomResult = safeRandomizerService.Next(min, max); } catch (Exception ex) { testException = ex; } Assert.True(testException is ArgumentOutOfRangeException, "Specifying a greater min than max value should return an ArgumentOutOfRangeException"); }