public void TestMakeGuess() { PhraseBoard b = new PhraseBoard("h i"); Assert.Equal(100, b.MakeGuess(100, 'h')); Assert.Equal(0, b.MakeGuess(100, 'a')); b = new PhraseBoard("a aaa a"); Assert.Equal(0, b.MakeGuess(100, 'b')); Assert.Equal(500, b.MakeGuess(100, 'a')); }
public void TestHasGuessed() { PhraseBoard b = new PhraseBoard("h i"); Assert.False(b.HasGuessed('h')); b.MakeGuess(500, 'h'); Assert.True(b.HasGuessed('h')); }
public void TestIsGameOver() { PhraseBoard b = new PhraseBoard("h i"); Assert.False(b.IsGameOver()); b.MakeGuess(500, 'h'); Assert.False(b.IsGameOver()); b.MakeGuess(500, 'i'); Assert.True(b.IsGameOver()); b = new PhraseBoard("h i"); Assert.False(b.IsGameOver()); b.MakeGuess("h i"); Assert.True(b.IsGameOver()); b = new PhraseBoard("abc"); Assert.False(b.IsGameOver()); b.MakeGuess("abc"); Assert.True(b.IsGameOver()); }
public void TestGetBoardString(string phrase, char[] guesses, string expected) { var sut = new PhraseBoard(phrase); foreach (var guess in guesses) { sut.MakeGuess(100, guess); } string actual = sut.GetBoardString(); Assert.Equal(expected, actual); }
public void UIGetSpinGuessLetter_Tests(string consoleInput, string phraseString, char[] guesses, char expected) { // Arrange var stringReader = new StringReader(Util.FormatConsoleInput(consoleInput)); Console.SetIn(stringReader); var sut = new GameUI(); var phraseBoard = new PhraseBoard(phraseString); var player = new Player("Player"); foreach (char guess in guesses) { var points = phraseBoard.MakeGuess(1000, guess); player.AddCurrentScore(points); } // Act var actual = sut.GetSpinGuessLetter(phraseBoard, player); // Assert Assert.Equal(expected, actual); }