public void ShouldFindThreeWhiteKeyPegsWhenCodeColorMatchesThreeOtherShieldPositions(CodePeg[] code) { //Arrange var boardConfig = new BoardConfig(4, 10); var decodingBoard = new DecodingBoard(boardConfig); var colors = new[] { CodePeg.Black, CodePeg.Blue, CodePeg.Green, CodePeg.White }; var shield = new Shield(colors); decodingBoard.CodeMaker(shield); //Act var result = decodingBoard.CodeBreaker(code); //Assert result.Should().NotBeNull(); result.WhiteKeyPegs.Should().Be(3); }
public void ShouldThrowArgumentNullExceptionWhenCodeBreakerCodeIsNull() { //Arrange var boardConfig = new BoardConfig(4, 10); var decodingBoard = new DecodingBoard(boardConfig); var colors = new[] { CodePeg.Black, CodePeg.Blue, CodePeg.Green, CodePeg.White }; var shield = new Shield(colors); decodingBoard.CodeMaker(shield); //Act void Action() => decodingBoard.CodeBreaker(null); var exception = Record.Exception(Action); //Assert exception.Should().BeOfType <ArgumentNullException>(); }
public void ShouldFindAllBlackKeyPegsWhenAllCodeColorsMatchShieldPosition() { //Arrange var boardConfig = new BoardConfig(4, 10); var decodingBoard = new DecodingBoard(boardConfig); var colors = new[] { CodePeg.Black, CodePeg.Blue, CodePeg.Green, CodePeg.White }; var shield = new Shield(colors); decodingBoard.CodeMaker(shield); var code = new[] { CodePeg.Black, CodePeg.Blue, CodePeg.Green, CodePeg.White }; //Act var result = decodingBoard.CodeBreaker(code); //Assert result.Should().NotBeNull(); result.BlackKeyPegs.Should().Be(colors.Length); result.WhiteKeyPegs.Should().Be(0); }