public void CanCreateNumberPickerWithExpectedNumber() { var displayHandler = new Mock <IDisplayHandler>().Object; const int expectedNumber = 42; var numberPicker = new NumberPicker(displayHandler, expectedNumber, expectedNumber); var canGuessExpectedNumber = numberPicker.GuessNumber(expectedNumber); Assert.True(canGuessExpectedNumber); }
public void CanFailToGuessNumber() { var displayHandler = new Mock <IDisplayHandler>().Object; const int actualNumber = 37; const int expectedNumber = 42; var numberPicker = new NumberPicker(displayHandler, actualNumber, actualNumber); var canGuessExpectedNumber = numberPicker.GuessNumber(expectedNumber); Assert.False(canGuessExpectedNumber); }
public void CanDisplayMessageToUserAfterGuess() { var displayHandler = new Mock <IDisplayHandler>(); displayHandler.Setup(mock => mock.DisplayMessage(It.IsAny <string>())); const int expectedNumber = 0; var numberPicker = new NumberPicker(displayHandler.Object, expectedNumber); numberPicker.GuessNumber(expectedNumber); displayHandler.Verify(mock => mock.DisplayMessage(It.IsAny <string>()), Times.Once); }
/// <summary> /// /// </summary> private void UserAttemptsGuess() { var userGuess = _displayHandler.GetUserGuess(); var userGuessResult = _computerChosenNumber.GuessNumber(userGuess); _displayHandler.Debug($"User Guess: {userGuess}"); //ToDo: remove later on _displayHandler.Debug($"User Guess Result: {userGuessResult}"); //ToDo: remove later on if (userGuessResult) { //ToDo: will need to do something janky here to make this work. Perhaps get the game object that displays the score and then increment that, treat the UI as if it is the source of truth. //_match.AddToPlayerScore(); } }