public void When_AllCompeting_Expect_AllCompetingMessage() { // Arrange var testGameEngine = new GameEngine(consoleMethods); consoleMethods.SimulatedInput = string.Join(" ", Enum.GetNames(typeof(Kingdoms))); var breakerOfChains = new BreakerOfChains(consoleMethods); // Act var actual = breakerOfChains.CustomInputAction(string.Empty, testGameEngine); // Assert Assert.AreEqual(Utility.TooManyKingdomsMessage, actual); }
public void When_InvalidInput_Expect_False(string input) { // Arrange var breakerOfChains = new BreakerOfChains(consoleMethods); // we cure the input as the user input is being converted to lower and // trimmed when being read from the console in the actual application input = input.ToLower().Trim(); // Act var actual = breakerOfChains.CustomInputValidator(input); // Assert Assert.IsFalse(actual, $"Failed for [{input}]"); }
public void When_NoCompetitor_Expect_NoCompetitorMessage(string input) { // Arrange var testGameEngine = new GameEngine(consoleMethods); // we cure the input as the user input is being converted to lower and // trimmed when being read from the console in the actual application input = input.ToLower().Trim(); consoleMethods.SimulatedInput = input; var breakerOfChains = new BreakerOfChains(consoleMethods); // Act var actual = breakerOfChains.CustomInputAction(input, testGameEngine); // Assert Assert.AreEqual(Utility.NoCompetingKingdomsMessage, actual); }
public void When_ValidKingdoms_Expect_RulerCrowned(string input) { // Arrange var testGameEngine = new GameEngine(consoleMethods); // we cure the input as the user input is being converted to lower and // trimmed when being read from the console in the actual application input = input.ToLower().Trim(); consoleMethods.SimulatedInput = input; var breakerOfChains = new BreakerOfChains(consoleMethods); // Act var actual = breakerOfChains.CustomInputAction(string.Empty, testGameEngine); // Assert Assert.That(testGameEngine.RulingKingdom != null || actual == Utility.BallotTookTooLongMessage); }
public void When_RoundsExceed_Expect_NoRuler(int maxRounds) { // Arrange Utility.listOfMessages.Clear(); Utility.listOfMessages.Add("123456789"); var testGameEngine = new GameEngine(consoleMethods); consoleMethods.SimulatedInput = $"{Kingdoms.Air} {Kingdoms.Ice}"; var breakerOfChains = new BreakerOfChains(consoleMethods); // Act var actual = breakerOfChains.CustomInputAction(string.Empty, testGameEngine); // Explicitly call Utility class' static constructor so as to revert changes to listOfMessages System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(typeof(Utility).TypeHandle); // Assert Assert.That(testGameEngine.RulingKingdom == null && actual == Utility.BallotTookTooLongMessage); }
public void When_OneValidOneInvalid_Expect_InvalidAndTooFewMessage(string input) { // Arrange var testGameEngine = new GameEngine(consoleMethods); // we cure the input as the user input is being converted to lower and // trimmed when being read from the console in the actual application input = input.ToLower().Trim(); consoleMethods.SimulatedInput = input; var breakerOfChains = new BreakerOfChains(consoleMethods); var invalidKingdom = input.Split(' ')[1]; var expected = string.Format(Utility.InvalidKingdomMessage, invalidKingdom); expected += Utility.NoCompetingKingdomsMessage; // Act var actual = breakerOfChains.CustomInputAction(string.Empty, testGameEngine); // Assert Assert.AreEqual(expected, actual); }