Beispiel #1
0
        public void TestBiodiversity(string input, int expectedOutput)
        {
            var inputWithoutNewLines = new string(input.Where(c => c == '#' || c == '.').ToArray());
            var grid = new Solver.ErisGrid(inputWithoutNewLines, false);

            Assert.AreEqual(expectedOutput, grid.GetBiodiversity());
        }
Beispiel #2
0
        public void TestRecursive(string input, int steps, int expectedOutput)
        {
            var inputWithoutNewLines = new string(input.Where(c => c == '#' || c == '.').ToArray());
            var grid = new Solver.ErisGrid(inputWithoutNewLines, true);

            grid.DoTimeSteps(steps);
            var output = grid.CountAllBugs(true);

            Assert.AreEqual(expectedOutput, output);
        }
Beispiel #3
0
        public void TestUpdate(string input, string expectedState)
        {
            var inputWithoutNewLines    = new string(input.Where(c => c == '#' || c == '.').ToArray());
            var expectedWithoutNewLines = new string(expectedState.Where(c => c == '#' || c == '.').ToArray());
            var expectedGrid            = new Solver.ErisGrid(expectedWithoutNewLines, false);
            var inputGrid = new Solver.ErisGrid(inputWithoutNewLines, false);

            inputGrid.Step();
            inputGrid.GetPrintableState().ToList().ForEach(s => System.Diagnostics.Trace.WriteLine(s));

            Assert.AreEqual(expectedGrid.GetBiodiversity(), inputGrid.GetBiodiversity());
        }