public void CanHandleGuessingWithBinarySearchEngine() { const int minimumNumber = 0; const int maximumNumber = 1000; const int expectedGuess = 500; var searchEngine = new BinarySearchEngine(minimumNumber, maximumNumber); var displayHandler = new Mock <IDisplayHandler>().Object; var handler = new GuessHandler(searchEngine, displayHandler); var actualGuess = handler.HandleGuess(minimumNumber, maximumNumber); Assert.Equal(expectedGuess, actualGuess); }
public void CanHandleGuessingWithMockSearchEngine() { const int minimumNumber = 0; const int maximumNumber = 1000; const int expectedGuess = 500; var searchEngine = new Mock <ISearchEngine>(); searchEngine.SetupGet(mock => mock.Guess).Returns(500); var displayHandler = new Mock <IDisplayHandler>().Object; var handler = new GuessHandler(searchEngine.Object, displayHandler); var actualGuess = handler.HandleGuess(minimumNumber, maximumNumber); searchEngine.VerifyGet(mock => mock.Guess, Times.Once); Assert.Equal(expectedGuess, actualGuess); }
/// <summary> /// Uses the Guess Handler to attempt the next guess. /// </summary> private void AttemptGuess() { _gameState = GameState.Guess; _guess = _guessHandler.HandleGuess(_minimumNumber, _maximumNumber); }