public static void Main(string[] args) { SecretGenerator secretGenerator = new SecretGenerator(); BullsAndCowsGame game = new BullsAndCowsGame(secretGenerator); var input = Console.ReadLine(); while (!game.IsInputValid(input)) { Console.WriteLine("Wrong Input, input again! \n"); input = Console.ReadLine(); } while (game.CanContinue()) { var output = game.Judge(input); if (output == "4A0B") { Console.WriteLine(output); break; } else { Console.WriteLine(output); input = Console.ReadLine(); } } Console.WriteLine("Game Over"); }
public static void Main(string[] args) { SecretGenerator secretGenerator = new SecretGenerator(); BullsAndCowsGame game = new BullsAndCowsGame(secretGenerator); while (game.CanContinue) { var input = Console.ReadLine(); if (!game.IsInputValid(input)) { Console.WriteLine("Wrong Input, input again"); continue; } var output = game.Guess(input); Console.WriteLine(output); if (output == "4A0B") { Console.WriteLine("You win"); break; } game.CountInputTimes(); } Console.WriteLine("Game Over"); }
public void Should_IsInputValid_Show_false(string guess) { //given var mockSecretGenerator = new Mock <SecretGenerator>(); var game = new BullsAndCowsGame(mockSecretGenerator.Object); //when var answer = game.IsInputValid(guess); //then Assert.Equal(false, answer); }
public void Should_CanContinue_return_true_when_input_invalid(string guess) { // given var mockSecretGenerator = new Mock <SecretGenerator>(); mockSecretGenerator.Setup(mock => mock.GenerateSecret()).Returns(string.Empty); var game = new BullsAndCowsGame(mockSecretGenerator.Object); // when var canContinue = game.IsInputValid(guess); // then Assert.True(canContinue); }