Beispiel #1
0
 public void IsLandmine2x2Test()
 {
     var landminesInstaller  = new DefaultLandmineInstaller();
     var landminesCalculator = new DefaultLandminesCalculator();
     var landminesDetector   = new DefaultLandmineDetector();
     var clearGroundFinder   = new DefaultClearGroundFinder();
     var board = new Board(2, 2, landminesInstaller, landminesCalculator, landminesDetector, clearGroundFinder);
 }
Beispiel #2
0
        public void IsFreeSpaceTest()
        {
            var landminesInstaller  = new NorthWestCornerLandmineInstaller4x4();
            var landminesCalculator = new DefaultLandminesCalculator();
            var landminesDetector   = new DefaultLandmineDetector();
            var clearGroundFinder   = new DefaultClearGroundFinder();
            var board      = new Board(4, 4, landminesInstaller, landminesCalculator, landminesDetector, clearGroundFinder);
            var freeSpaces = board.GetFreeSpaces(0, 3);
            var output     = new byte[4, 4];

            foreach (var eachFreeSpace in freeSpaces)
            {
                output[eachFreeSpace.DimesionX, eachFreeSpace.DimensionY] = 9;
            }
            var outputString = board.DisplayBoard(output);
        }
        public void DetectLandminesTest()
        {
            var defaultLandmineDetector = new DefaultLandmineDetector();

            board = new byte[4, 4] {
                { 0, 0, 0, landMine }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
            };
            var expectedOutput = "0019001100000000";

            defaultLandmineDetector.DetectLandmines(board, landMine, IsLandmine);
            var outputAccumulator = new StringBuilder();

            for (int rowindex = 0; rowindex < board.GetLength(0); rowindex++)
            {
                for (int columnIndex = 0; columnIndex < board.GetLength(1); columnIndex++)
                {
                    outputAccumulator.Append(board[rowindex, columnIndex]);
                }
            }
            Assert.AreEqual(expectedOutput, outputAccumulator.ToString());
        }