public void TestCreateGrid()
 {
     ChristmasLightsGrid grid = new ChristmasLightsGrid();
     int columns = 10;
     int rows = 10;
     grid.Columns = columns;
     grid.Rows = rows;
     grid.GenerateGridCommand.Execute(null);
     Assert.AreEqual(columns * rows, grid.Lights.Count, "Grid cell count do not match.");
 }
 public void TestSetGrid()
 {
     ChristmasLightsGrid grid = new ChristmasLightsGrid();
     int expectedRows = 10;
     int expectedColumns = 20;
     Assert.AreEqual(0, grid.Columns);
     Assert.AreEqual(0, grid.Rows);
     grid.Columns = expectedColumns;
     grid.Rows = expectedRows;
     Assert.AreEqual(expectedColumns, grid.Columns, "Column test failed");
     Assert.AreEqual(expectedRows, grid.Rows, "Row test failed");
 }
 public void TestToggle1000Lights()
 {
     ChristmasLightsGrid grid = new ChristmasLightsGrid();
     int columns = 1000;
     int rows = columns;
     List<string> instructionsList = new List<string> { "toggle 0,0 through 999,0" };
     grid.Columns = columns;
     grid.Rows = rows;
     grid.Instructions = instructionsList;
     grid.GenerateGridCommand.Execute(null);
     grid.FollowInstructionsCommand.Execute(null);
     int actual = grid.Lights.Count(x => x.Lit);
     Assert.AreEqual(1000, actual, $"Some lights failed to turn on. Total lights on: {actual}.");
 }
Beispiel #4
0
        static void Main(string[] args)
        {
            int cols = 1000;
            int rows = cols;
            List<string> instructionList = File.ReadAllLines("input.txt").ToList();

            //new List<string>
            //{
            //    "toggle 0,0 through 999,999"
            //};
            _grid = new ChristmasLightsGrid
                    {
                        Columns = cols,
                        Rows = rows,
                        Lights = new List<ChristmasLight>()
                    };

            Part1(instructionList);
            Part2(instructionList);
            Console.Write("Press any key.");
            Console.ReadKey();
        }
 public void TestSetGridDimensions()
 {
     ChristmasLightsGrid grid = new ChristmasLightsGrid();
     int columns = 10;
     int rows = 10;
     grid.Columns = columns;
     grid.Rows = rows;
     Assert.AreEqual(columns, grid.Columns, "Columns do not match");
     Assert.AreEqual(rows, grid.Rows, "Rows do not match");
     try
     {
         columns = -1;
         rows = -1;
         grid.Columns = columns;
         grid.Rows = rows;
         Assert.AreEqual(columns, grid.Columns);
         Assert.AreEqual(rows, grid.Rows);
     }
     catch (ArgumentOutOfRangeException e)
     {
         StringAssert.Contains(e.Message, ChristmasLightsGrid.ArgumentOutOfRangeMessage);
     }
 }