public void TestGetArgumentToReturnCorrectNumberToMove() { var mockedReader = new Mock<HelperReader>(); Console.SetIn(mockedReader.Object); IList<int> moveCommands = new List<int>() { 1, 2, 2, 3, 4, 58, 1001, 60123, 1231, 123, 12, 31, 312, 3131312, 123, 1 }; IUserInterface interf = new ConsoleInterface(); dynamic result; int indexOfCommand = 0; mockedReader.Setup(r => r.ReadLine()).Returns(() => moveCommands[indexOfCommand].ToString()); bool actual; for (; indexOfCommand < moveCommands.Count; indexOfCommand++) { interf.GetCommandFromInput(); result = interf.GetArgumentValue(GlobalConstants.DestinationTileValue); actual = (result as int? == moveCommands[indexOfCommand]); Assert.IsTrue(actual); } mockedReader.Verify(r => r.ReadLine(), Times.Exactly(moveCommands.Count)); }
public void TestToThrowExceptonWhenInvalidArgumentIsPassed() { IUserInterface interf = new ConsoleInterface(); dynamic result = interf.GetArgumentValue("InvlaidArgument"); }
public void TestToGetArgumnetValueReturnCorectValue() { var mockedReader = new Mock<HelperReader>(); Console.SetIn(mockedReader.Object); IList<string> styleCommands = new List<string>() { "style=dotted", "style=solid", "style=fat", "style=double" }; int indexOfCommands = 0; mockedReader.Setup(r => r.ReadLine()).Returns(() => styleCommands[indexOfCommands]); IUserInterface interf = new ConsoleInterface(); dynamic result; bool actual; for (; indexOfCommands < styleCommands.Count; indexOfCommands++) { interf.GetCommandFromInput(); result = interf.GetArgumentValue(GlobalConstants.GridBorderStyle); actual = (result as string == styleCommands[indexOfCommands].Replace("style=", string.Empty)); Assert.IsTrue(actual); } mockedReader.Verify(r => r.ReadLine(), Times.Exactly(styleCommands.Count)); }