Exemplo n.º 1
0
        public void TestRender()
        {
            IRenderer render = new ConsoleRenderer();
            ICellFactory factory = new GridCellFactory(4, 4);
            IPlayField playField = new GridPlayField(factory,4, 4);
            playField.InitializePlayField("0010001000100010");
            using (var sw = new StringWriter())
            {
                Console.SetOut(sw);

                using (var sr = new StringReader(""))
                {
                    Console.SetIn(sr);

                    render.Render(playField);

                    string expected = string.Format("  # {0}  # {1}  # {2}  # {3}", Environment.NewLine,
                                                    Environment.NewLine, Environment.NewLine, Environment.NewLine);
                    /*  
                    * | | |#| |
                    * | | |#| |
                    * | | |#| |
                    * | | |#| |
                    */
                    Assert.AreEqual(expected, sw.ToString());
                }
            }
        }
Exemplo n.º 2
0
 public void TestGetCells()
 {
     ICellFactory factory = new GridCellFactory(4, 4);
     IPlayField playField = new GridPlayField(factory,4, 4);
     playField.InitializePlayField("01001101001");
     AbstractCell[,] cells = playField.GetCells();
     for (int i = 0; i < 4; i++)
         for (int j = 0; j < 4; j++)
             Assert.AreEqual(cells[i, j], playField.GetCell(i, j));
 }
Exemplo n.º 3
0
 public void TestInvalidGetCell()
 {
     try
     {
         ICellFactory factory = new GridCellFactory(4, 4);
         IPlayField playField = new GridPlayField(factory,4, 4);
         playField.InitializePlayField("01001101001");
         playField.GetCell(-1, -2);
     }
     catch (Exception exception)
     {
         Assert.AreEqual("row should be between 0 to 3 and column should be between 0 to 3", exception.Message);
         throw;
     }
 }