コード例 #1
0
        public void CanFindASingleBlock()
        {
            var results = default(IEnumerable<Block>);
            var board = default(IBoard);
            var blockFinder = default(BlockFinder);

            "Given I have a board that contains one block".Context(() =>
            {
                board = new BoardFactory().Create();
                var boardFillerOneBlock = new BoardFillerOneBlock();
                boardFillerOneBlock.Fill(board);
                blockFinder = new BlockFinder();
            });

            "When I find blocks".Do(() => results = blockFinder.Find(board));

            "Then 1 block should be returned"
                .Observation(() => results.Count().ShouldEqual(1));

            "Then 1 board coordinate should be at 3, 1"
                .Observation(() => results.First().BoardCoordinates.Count(s => s.X == 3 && s.Y == 1).ShouldEqual(1));

            "Then 1 board coordinate should be at 4, 1"
               .Observation(() => results.First().BoardCoordinates.Count(s => s.X == 4 && s.Y == 1).ShouldEqual(1));

            "Then 1 board coordinate should be at 3, 2"
               .Observation(() => results.First().BoardCoordinates.Count(s => s.X == 3 && s.Y == 2).ShouldEqual(1));

            "Then 1 board coordinate should be at 4, 2"
               .Observation(() => results.First().BoardCoordinates.Count(s => s.X == 4 && s.Y == 2).ShouldEqual(1));
        }
コード例 #2
0
        public void CanFindMultipleBlocksInDifferentPartsOfGrid()
        {
            var results = default(IEnumerable<Block>);
            var board = default(IBoard);
            var blockFinder = default(BlockFinder);

            "Given I have a board that contains two blocks".Context(() =>
            {
                board = new BoardFactory().Create();
                var boardFillerTwoBlocks = new BoardFillerTwoBlocks();
                boardFillerTwoBlocks.Fill(board);
                blockFinder = new BlockFinder();
            });

            "When I find blocks".Do(() => results = blockFinder.Find(board));

            "Then 2 blocks should be returned"
                .Observation(() => results.Count().ShouldEqual(2));

            "Then 1 board coordinate in the first block should be at 3, 1"
                .Observation(() => results.First().BoardCoordinates.Count(s => s.X == 3 && s.Y == 1).ShouldEqual(1));

            "Then 1 board coordinate in the first block should be at 4, 1"
               .Observation(() => results.First().BoardCoordinates.Count(s => s.X == 4 && s.Y == 1).ShouldEqual(1));

            "Then 1 board coordinate in the first block should be at 3, 2"
               .Observation(() => results.First().BoardCoordinates.Count(s => s.X == 3 && s.Y == 2).ShouldEqual(1));

            "Then 1 board coordinate in the first block should be at 4, 2"
               .Observation(() => results.First().BoardCoordinates.Count(s => s.X == 4 && s.Y == 2).ShouldEqual(1));

            "Then 1 board coordinate in the second block should be at 3, 6"
               .Observation(() => results.ToList()[1].BoardCoordinates.Count(s => s.X == 3 && s.Y == 6).ShouldEqual(1));

            "Then 1 board coordinate in the second block should be at 4, 6"
               .Observation(() => results.ToList()[1].BoardCoordinates.Count(s => s.X == 4 && s.Y == 6).ShouldEqual(1));

            "Then 1 board coordinate in the second block should be at 3, 7"
               .Observation(() => results.ToList()[1].BoardCoordinates.Count(s => s.X == 3 && s.Y == 7).ShouldEqual(1));

            "Then 1 board coordinate in the second block should be at 4, 7"
               .Observation(() => results.ToList()[1].BoardCoordinates.Count(s => s.X == 4 && s.Y == 7).ShouldEqual(1));
        }
コード例 #3
0
        public void CanDetectWhenThereAreNoBlocksPresent()
        {
            var results = default(IEnumerable<Block>);
            var board = default(IBoard);
            var blockFinder = default(BlockFinder);

            "Given I have a board that contains no blocks".Context(() =>
                {
                    board = new BoardFactory().Create();
                    var numericalBoardFiller = new NumericalBoardFiller();
                    numericalBoardFiller.Fill(board);
                    blockFinder = new BlockFinder();
                });

            "When I find blocks".Do(() => results = blockFinder.Find(board));

            "Then no blocks should be returned"
                .Observation(() => results.Count().ShouldEqual(0));
        }