Beispiel #1
0
        static void Main(string[] args)
        {
            var tableDimension = new TableDimension(
                width: int.Parse(ConfigurationManager.AppSettings["table_width"]),
                hight: int.Parse(ConfigurationManager.AppSettings["table_hight"]));
            var    context = new Context(new Robert(tableDimension), Console.Out);
            string commandLine;

            while (!string.IsNullOrEmpty((commandLine = Console.ReadLine())))
            {
                CommandFactory
                .Parse(commandLine)
                .Do(context);
            }
        }
        private static void TestExample(string expectedOutput, string[] commandLines)
        {
            // Given
            var writer         = new Mock <TextWriter>();
            var tableDimension = new TableDimension(width: 5, hight: 5);
            var context        = new Context(new Robert(tableDimension), writer.Object);

            // When
            commandLines
            .Select(CommandFactory.Parse)
            .ToList()
            .ForEach(command => command.Do(context));

            // Then
            writer.Verify(r => r.WriteLine(expectedOutput));
        }
Beispiel #3
0
 public Robert(TableDimension tableDimension)
 {
     TableDimension = tableDimension;
 }
Beispiel #4
0
 private static bool IsOnTable(TableDimension tableDimension, Position position)
 => position.X >= 0 &&
 position.Y >= 0 &&
 position.X < tableDimension.Width &&
 position.Y < tableDimension.Hight;