private bool IsValidOne(string input) { var pwl = new PasswordLine(input); var count = pwl.Password.Where(c => c == pwl.Letter).Count(); return(count >= pwl.FirstNumber && count <= pwl.SecondNumber); }
public bool IsValid(PasswordLine line) { var requiredCharCount = line.Password.Count(c => c == line.RequiredChar); // Lower and Upper bound are both inclusive. return(requiredCharCount >= line.LowerBound && requiredCharCount <= line.UpperBound); }
public bool IsValid(PasswordLine line) { // Bounds are the positions, and are one-based indexes. var isAt1 = line.Password[line.LowerBound - 1] == line.RequiredChar; var isAt2 = line.Password[line.UpperBound - 1] == line.RequiredChar; return(isAt1 ^ isAt2); }
public void ThrowsForInvalidInputs(string inputLine) { Action action = () => PasswordLine.Parse(inputLine); // ACT & ASSERT action.Should().Throw <InvalidOperationException>() .WithMessage("Invalid password line: " + inputLine); }
public void ParsesValidInputs( string inputLine, int expectedLowerBound, int expectedUpperBound, char expectedRequiredChar, string expectedPassword) { // ACT var result = PasswordLine.Parse(inputLine); // ASSERT result.Should().BeEquivalentTo( new PasswordLine(expectedLowerBound, expectedUpperBound, expectedRequiredChar, expectedPassword)); }
private bool IsValidTwo(string input) { var pwl = new PasswordLine(input); return(pwl.Password[pwl.FirstNumber - 1] == pwl.Letter ^ pwl.Password[pwl.SecondNumber - 1] == pwl.Letter); }