public void EachAnimationWillDecreaseTheOffset() { var board = default(IBoard); var blocksFallingAnimation = default(BlocksFallingAnimation); "Given I have a standard board and a known list of coordinates".Context(() => { board = new BoardFactory().Create(); var boardCoordinates = new List<BoardCoordinate> { new BoardCoordinate(1, 2), new BoardCoordinate(2, 3) }; board[1, 2].YOffset = 200; board[2, 3].YOffset = 200; blocksFallingAnimation = new BlocksFallingAnimation(boardCoordinates, board); }); "When I call animate after 100 milliseconds has passed" .Do(() => blocksFallingAnimation.Animate(new GameTime { ElapsedGameTime = TimeSpan.FromMilliseconds(100) })); "Then the square at 1, 2 should have a yoffset of 200 - block fall speed * 100".Observation( () => board[1, 2].YOffset.ShouldEqual((float)(200 - GameConstants.Animation.BLOCK_FALL_SPEED * 100))); "Then the square at 2, 3 should have a yoffset of 200 - block fall speed * 100".Observation( () => board[1, 2].YOffset.ShouldEqual((float)(200 - GameConstants.Animation.BLOCK_FALL_SPEED * 100))); "Then 2 squares will have a y offset higher than 0".Observation( () => board.AllSquares().Count(sq => sq.YOffset != 0).ShouldEqual(2)); }
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)); }
public void CanSelectSquareFiveAcrossSixDownCorrectly() { SquareSelector squareSelector = default(SquareSelector); Board board = null; "Given I have a standard board with no squares selected and a square selector".Context(() => { board = new BoardFactory().Create(); squareSelector = new SquareSelector(); }); "When I select the centre square 5, 6".Do(() => squareSelector.Select(board, 5, 6)); "Then square 5, 6 should be the main selection".Observation(() => board[5, 6].IsMainSelection.ShouldBeTrue()); "Then the square at position 5, 5 should be selected".Observation(() => board[5, 5].IsSelected.ShouldBeTrue()); "Then the square at position 5, 6 should be selected".Observation(() => board[5, 6].IsSelected.ShouldBeTrue()); "Then the square at position 5, 7 should be selected".Observation(() => board[5, 7].IsSelected.ShouldBeTrue()); "Then the square at position 4, 6 should be selected".Observation(() => board[4, 6].IsSelected.ShouldBeTrue()); "Then the square at position 6, 6 should be selected".Observation(() => board[6, 6].IsSelected.ShouldBeTrue()); "Then there should be a total of 5 selected squares".Observation( () => board.AllSquares().Count(sq => sq.IsSelected).ShouldEqual(5)); }
public void RotateLeftAnimationInitialisesSquaresToPlus90() { var board = default(IBoard); var rotateLeftAnimation = default(RotateLeftAnimation); var boardCoordinates = default(IEnumerable<BoardCoordinate>); "Given I have a standard board and a known list of coordinates".Context(() => { board = new BoardFactory().Create(); boardCoordinates = new[] { new BoardCoordinate(1, 2), new BoardCoordinate(2, 3) }; }); "When I create a new rotateLeftAnimation".Do( () => rotateLeftAnimation = new RotateLeftAnimation(boardCoordinates, board)); "Then the square at coordinate 1, 2 will have an angle of 90".Observation( () => board[1, 2].Angle.ShouldEqual(90)); "Then the square at coordinate 2, 3 will have an angle of 90".Observation( () => board[2, 3].Angle.ShouldEqual(90)); "Then 2 squares will have an angle of -90".Observation( () => board.AllSquares().Count(sq => sq.Angle == 90).ShouldEqual(2)); "Then the animation should not be finished".Observation( () => rotateLeftAnimation.Finished().ShouldBeFalse()); }
public void CanOnlyRotateTheSelectedSquaresWhenRotatingRight() { var selectionRotator = new SelectionRotatator(); var board = default(Board); var result = default(RotatedRightEvent); "Given that I have a board with 5 selected squares".Context(() => { GameEvents.Dispatcher = new ActionEventDispatcher(a => result = a as RotatedRightEvent); board = new BoardFactory().Create(); new NumericalBoardFiller().Fill(board); board[4, 4].IsMainSelection = true; board[4, 4].IsSelected = true; board[4, 5].IsSelected = true; board[4, 3].IsSelected = true; board[3, 4].IsSelected = true; board[5, 4].IsSelected = true; }); "When I rotate the board right".Do(() => selectionRotator.Right(board)); "Then a rotated right event should be raised".Observation(() => result.ShouldNotBeNull()); "Then 4 squares should be in the event".Observation(() => result.BoardCoordinates.Count().ShouldEqual(4)); }
public void TestFillStriped() { SudokuBoard board = new SudokuBoard(); BoardFactory.FillSequential(board); Assert.AreEqual(1, board.Row(0)[0]); Assert.AreEqual(2, board.Row(1)[0]); Assert.AreEqual(6, board.Row(1)[4]); }
public void SetUp() { dice = new LoadedDice(); player1 = "Horse"; players = new List<String> { player1 }; banker = new Banker(players, 1500); var boardFactory = new BoardFactory(); var guard = new PrisonGuard(banker, dice); board = boardFactory.Create(banker, players, dice, guard); }
public GameData() { Board = BoardFactory.BuildNewBoard(); Deck = BoardFactory.BuildDeck(); Players = BoardFactory.BuildPlayers(); Plays = new List <Play>(); TurnNumber = 1; Won = false; HighestPlayable = 99; }
public void AssertBoardIsValidated() { BoardFactory boardFactory = GetBoardFactory(out BoardFactoryContext boardFactoryContext); boardFactoryContext.LegalBoardValidator.Setup(lbv => lbv.Validate(It.IsAny <List <Tile> >(), 4)).Returns(true); Board board = boardFactory.Build(4); boardFactoryContext.LegalBoardValidator.Verify(lbv => lbv.Validate(It.IsAny <List <Tile> >(), 4), Times.AtLeastOnce); }
public void FailOnIllegalNumberOfBlankTiles() { BoardFactory boardFactory = GetBoardFactory(out BoardFactoryContext boardFactoryContext); int dontcare; boardFactoryContext.BlankTileIndexFinder.Setup(btif => btif.TryFind(It.IsAny <List <Tile> >(), out dontcare)).Returns(false); boardFactoryContext.LegalBoardValidator.Setup(lbv => lbv.Validate(It.IsAny <List <Tile> >(), 4)).Returns(true); Assert.Throws <Exception>(() => boardFactory.Build(4)); }
public static void simple2Workers() { var board = BoardFactory.LoadBoardFromFen(); var ai = new AIWorkerManager(); ai.spawnWorkers(2); ai.analyzeBoard(board, 2).GetAwaiter().GetResult(); Assert.IsTrue(MoveHelper.isValidMove(ai.GetBestMove().move)); }
public void EmptyBoard() { var board = BoardFactory.CreateBoard(height: 3, width: 3, mines: 0); var allFields = board.AllFields; Assert.Equal(9, allFields.Count()); Assert.Equal(0, board.Mines.Count()); Assert.True(allFields.All(point => !board.HasBomb(point))); }
public void SanitizeFenCastling() { // this fen is technically illegal because you cannot castle while the king isn't on the correct position // if it is not sanitized it will cause the program to crash var poisionFEN = "3r3k/6pp/3Q4/q7/8/4P2P/6P1/5RK1 b Qq - 0 1"; var board = BoardFactory.LoadBoardFromFen(poisionFEN); Assert.AreEqual(CastlingBits.EMPTY, board.CastlingBits); }
public Board TakeEnpassant() { /* Starting position +---------------+ |r n b q k b n r| 8 |p p _ p p p p p| 7 |_ _ _ _ _ _ _ _| 6 |_ _ _ _ _ _ _ _| 5 |_ _ _ p _ _ _ _| 4 |_ _ _ _ _ _ _ _| 3 |P P P P P P P P| 2 |R N B Q K B N R| 1 +---------------+ * A B C D E F G H * White creates opening for enPassant +---------------+ |r n b q k b n r| 8 |p p _ p p p p p| 7 |_ _ _ _ _ _ _ _| 6 |_ _ _ _ _ _ _ _| 5 |_ _ _ p P _ _ _| 4 |_ _ _ _ _ _ _ _| 3 |P P P P _ P P P| 2 |R N B Q K B N R| 1 +---------------+ * A B C D E F G H * Black enpassant +---------------+ |r n b q k b n r| 8 |p p _ p p p p p| 7 |_ _ _ _ _ _ _ _| 6 |_ _ _ _ _ _ _ _| 5 |_ _ _ _ _ _ _ _| 4 |_ _ _ _ p _ _ _| 3 |P P P P _ P P P| 2 |R N B Q K B N R| 1 +---------------+ * A B C D E F G H */ Board board = BoardFactory.LoadBoardFromFen("rnbqkbnr/pp1ppppp/8/8/3p4/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"); List <Move> list = board.GetMovesForPosition(BoardStateOffset.E2); Move move = list.FindTargetPosition(BoardStateOffset.E4); board.Move(move); list = board.GetMovesForPosition(BoardStateOffset.D4); move = list.FindTargetPosition(BoardStateOffset.E3); board.Move(move); return(board); }
/// <summary> /// Searches for a real classic stream deck or creates a virtual one. /// All examples are designed for the 5x3 classic StreamDeck. /// </summary> /// <returns></returns> public static IMacroBoard OpenBoard() { var realDeck = StreamDeck.EnumerateDevices(Hardware.StreamDeck).FirstOrDefault(); if (!(realDeck is null)) { return(realDeck.Open()); } return(BoardFactory.SpawnVirtualBoard(Hardware.StreamDeck.Keys)); }
private static List <Line> GetLines(string fileName, Cell cell) { var board = BoardExportImport.Import(Path.Combine(folder, fileName)); var game = new Game(board); var owner = board.WhoMovedLast(); var lines = game.GetLines(owner); board[cell.X, cell.Y] = owner.Opponent(); BoardFactory.AddCellToLines(cell, new BoardStateBase(new List <Line>(), lines, owner.Opponent(), board)); return(lines); }
private static void DoEvaluate() { //var fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"; var fen = "r4rk1/p2n1ppp/3qp3/6B1/N5P1/3P1b2/PPP1BbP1/R2Q1R1K b - - 0 14"; var boardFactory = new BoardFactory(); var board = boardFactory.ParseFEN(fen); var evaluationService = new EvaluationService(); var evaluation = evaluationService.Evaluate(board, null); Console.WriteLine(evaluation); }
public void SimpleFenTest() { Board board = BoardFactory.LoadBoardFromFen(); //Piece piece = Board.GetPiece(board, BoardOffset.A1); //Piece piece = board.A1; Assert.AreEqual(board.GetPiece(BoardStateOffset.A1), Piece.IS_WHITE | Piece.ROOK); Assert.AreEqual(board.GetPiece(BoardStateOffset.E1), Piece.IS_WHITE | Piece.KING); Assert.AreEqual(board.GetPiece(BoardStateOffset.E8), Piece.KING); }
private static List <Line> GetChangedLines(string fileName, Cell cell, bool movesInOrder = false) { var board = BoardExportImport.Import(Path.Combine(folder, fileName)); var game = new Game(board); var owner = movesInOrder ? board.WhoMovesNext() : board.WhoMovedLast(); var lines = game.GetLines(owner); board[cell.X, cell.Y] = owner; BoardFactory.AddCellToLines(cell, new BoardStateBase(lines, new List <Line>(), owner, board)); return(lines); }
public void undoStressTest5() { var board = BoardFactory.LoadBoardFromFen("r5k1/5ppp/1p6/p1p5/7b/1PPrqPP1/1PQ4P/R4R1K b - - 0 1"); var original = board.CreateCopy(); foreach (var move in board.GetMoves()) { board.Move(move); board.UndoMove(move); everyThingIsEqual(original, board, move); } }
public void undoStressTest4() { var board = BoardFactory.LoadBoardFromFen("r2qkb1r/ppP2ppp/2n2n2/6B1/3pN1b1/P7/2P1BPPP/R2QK1NR w KQkq - 0 10"); var original = board.CreateCopy(); foreach (var move in board.GetMoves()) { board.Move(move); board.UndoMove(move); everyThingIsEqual(original, board, move); } }
public void undoStressTest1() { var board = BoardFactory.LoadBoardFromFen(); var original = board.CreateCopy(); foreach (var move in board.GetMoves()) { board.Move(move); board.UndoMove(move); everyThingIsEqual(original, board, move); } }
public void SetUp() { factory = new BoardFactory(new RowTranslator('*', '.')); dimensions = "4 8"; var initialLayout = new List<String> { "........", "....*...", "...**...", "........" }; var data = new GameData { Dimensions = dimensions, Rows = initialLayout }; board = factory.GetBoard(data); }
public void BlackPromotionStressUndoTest() { var board = BoardFactory.LoadBoardFromFen("1nbqkbnr/rppppppp/p7/8/1P6/P1P5/1p1PPPPP/R1BQKBNR b KQk - 0 3"); var original = board.CreateCopy(); var moves = board.GetMoves(); foreach (var move in moves) { board.Move(move); board.UndoMove(move); } }
public static void defendAgainstMate() { /* * Starting position (White to play) +---------------+ |_ _ _ _ _ _ k _| 8 |_ _ _ _ _ _ _ _| 7 |_ _ _ _ _ _ _ _| 6 |_ _ _ r _ _ _ _| 5 |_ _ _ _ _ _ _ _| 4 |_ _ _ _ p _ p _| 3 |_ _ _ _ P _ P _| 2 |_ _ N _ _ _ K _| 1 +---------------+ * A B C D E F G H * C1 -> D3 (expected line to protect against mate on D1) +---------------+ |_ _ _ _ _ _ k _| 8 |_ _ _ _ _ _ _ _| 7 |_ _ _ _ _ _ _ _| 6 |_ _ _ r _ _ _ _| 5 |_ _ _ _ _ _ _ _| 4 |_ _ _ N p _ p _| 3 |_ _ _ _ P _ P _| 2 |_ _ _ _ _ _ K _| 1 +---------------+ * A B C D E F G H * D5 -> D3 +---------------+ |_ _ _ _ _ _ k _| 8 |_ _ _ _ _ _ _ _| 7 |_ _ _ _ _ _ _ _| 6 |_ _ _ _ _ _ _ _| 5 |_ _ _ _ _ _ _ _| 4 |_ _ _ r p _ p _| 3 |_ _ _ _ P _ P _| 2 |_ _ _ _ _ _ K _| 1 +---------------+ * A B C D E F G H */ var board = BoardFactory.LoadBoardFromFen("6k1/8/8/3r4/8/4p1p1/4P1P1/2N3K1 w - - 0 1"); var moves = board.GetMoves(); var aiWorkers = new AIWorkerManager(); aiWorkers.spawnWorkers(3); aiWorkers.analyzeBoard(board, 3).Wait(); aiWorkers.killWorkers(); EvaluatedMove foundMove = aiWorkers.GetBestMove(); // the rook has to move to e3 to defend against mate(d4->e2) Assert.AreEqual(BoardStateOffset.D3, foundMove.move.targetPosition); }
public InternalPerftClient(MoveGenerator moveGenerator, BoardFactory boardFactory) { _moveGenerator = moveGenerator; _boardFactory = boardFactory; _moves = new Move[SearchConstants.MaxDepth][]; for (var i = 0; i < SearchConstants.MaxDepth; i++) { _moves[i] = new Move[218]; } SetBoard("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"); }
public void GameFactoryReturnsGame() { //Arrange UserInterface userInterface = new UserInterface(new Utility()); BoardFactory boardFactory = new BoardFactory(); PlayerFactory playerFactory = new PlayerFactory(); //Act GameProcessor gameProcessor = new GameProcessor(userInterface, boardFactory, playerFactory); //Asset Assert.That(gameProcessor, Is.TypeOf <GameProcessor>()); }
public void CheckMateRegisteredTest() { char[,] boardLayout = { { 'e', 'e', 'e', 'e', 'K', 'e', 'e', 'e' }, { 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'c' }, { 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e' }, { 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e' }, { 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e' }, { 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e' }, { 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e' }, { 'e', 'e', 'e', 'e', 'k', 'e', 'c', 'e' } }; boardLayout = boardLayout.RotateArray(); Board board = BoardFactory.CreateBoard(boardLayout); BasicPlayer player1 = new BasicPlayer(board, Player.PlayerOne); board.AddPlayer(player1); BasicPlayer player2 = new BasicPlayer(board, Player.PlayerTwo); board.AddPlayer(player2); bool checkMate = false; Player winningPlayer = Player.None; board.OnGameStateChanged += delegate(GameState state) { if (state != GameState.WonByCheckmate) { return; } checkMate = true; winningPlayer = board.PlayerTurn; }; Vector2I castlePos = new Vector2I(6, 0); Assert.IsTrue(board.BoardPieces[castlePos.X, castlePos.Y].PieceType == PieceType.Castle); Vector2I castleDest = new Vector2I(6, 7); Assert.IsTrue(board.BoardPieces[castleDest.X, castleDest.Y].PieceType == PieceType.None); BoardPieceMove move = new BoardPieceMove(castlePos, castleDest); player1.ApplyMove(move); Assert.IsTrue(checkMate); Assert.AreEqual(GameState.WonByCheckmate, board.GameState); Assert.AreEqual(winningPlayer, Player.PlayerOne); }
public GameBoardSpawner(Settings settings, GameInfo info, BoardFactory boardFactory, StickFactory stickFactory, StickPartitionFactory stickPartitionFactory) { _Settings = settings; Info = info; _BoardFactory = boardFactory; _StickFactory = stickFactory; _StickPartitionFactory = stickPartitionFactory; }
public void SolvePuzzle() { var board = BoardFactory.CreateRedDonkeyPuzzle(); var someSuperIntelligentPerson = new SomeSuperIntelligentPerson(); var solution = someSuperIntelligentPerson.SolvePuzzle(board); var solutionViewer = new SolutionViewer(); solutionViewer.ShowSolution(board, solution); }
static void Main(string[] args) { string defFilePath = args[0]; if (IsPathValid(defFilePath)) { try { string[] lines = File.ReadAllLines(defFilePath); BoardFactory brdFactory = new BoardFactory(); Board board = brdFactory.BuildBoard(lines[0]); RoomFactory rmFactory = new RoomFactory(); for (int w = 0; w <= board.Width - 1; w++) { for (int h = 0; h <= board.Height - 1; h++) { Room rm = rmFactory.BuildRoom(w, h); board.Rooms.Add(rm); } } MirrorFactory mrFactory = new MirrorFactory(); int i = 2; string line = lines[i]; while (line != "-1") { Mirror mirror = mrFactory.BuildMirror(line); i++; line = lines[i]; board.AddMirror(mirror); } LaserFactory laserFactory = new LaserFactory(); Laser laser = laserFactory.BuildLaser(lines[lines.Count() - 2]); board.SetLaserDirection(laser); string exitConditions = board.FindExit(laser); Console.WriteLine($" Dimensions of Board: {board.Width}, {board.Height}\n Laser Starting Position {laser.XLoc}, {laser.YLoc}\n Laser Exit is at {exitConditions}"); } catch (Exception ex) { Console.WriteLine($"Error Occurred! Exception: {ex.Message} \nStackTrace\n: {ex.StackTrace}"); } } else { Console.WriteLine("File is not found or is invalid. Please select a new file."); } }
public void Basic2() { // X X O R // O X R R // R R X O // R O X X const uint BlackColor = 1; const uint RedColor = 2; Constraint blackConstr = new Constraint(BlackColor, 1); Constraint blackConstr2 = new Constraint(BlackColor, 2); Constraint redConstr = new Constraint(RedColor, 1); Constraint redConstr2 = new Constraint(RedColor, 2); var row0 = BoardFactory.CreateConstraintSet(new[] { blackConstr2, redConstr }); var row1 = BoardFactory.CreateConstraintSet(new[] { blackConstr, redConstr2 }); var row2 = BoardFactory.CreateConstraintSet(new[] { redConstr2, blackConstr }); var row3 = BoardFactory.CreateConstraintSet(new[] { redConstr, blackConstr2 }); var col0 = BoardFactory.CreateConstraintSet(new[] { blackConstr, redConstr2 }); var col1 = BoardFactory.CreateConstraintSet(new[] { blackConstr2, redConstr }); var col2 = BoardFactory.CreateConstraintSet(new[] { redConstr, blackConstr2 }); var col3 = BoardFactory.CreateConstraintSet(new[] { redConstr2, blackConstr }); var rowConstraints = new[] { row0, row1, row2, row3 }; var colConstraints = new[] { col0, col1, col2, col3 }; IBoard board = BoardFactory.CreateBoard(rowConstraints, colConstraints, RedColor); ISolvedBoard solvedBoard = board.Solve(); Assert.True(solvedBoard[0, 0] == BlackColor); Assert.True(solvedBoard[0, 1] == BlackColor); Assert.True(solvedBoard[0, 2] == 0); Assert.True(solvedBoard[0, 3] == RedColor); Assert.True(solvedBoard[1, 0] == 0); Assert.True(solvedBoard[1, 1] == BlackColor); Assert.True(solvedBoard[1, 2] == RedColor); Assert.True(solvedBoard[1, 3] == RedColor); Assert.True(solvedBoard[2, 0] == RedColor); Assert.True(solvedBoard[2, 1] == RedColor); Assert.True(solvedBoard[2, 2] == BlackColor); Assert.True(solvedBoard[2, 3] == 0); Assert.True(solvedBoard[3, 0] == RedColor); Assert.True(solvedBoard[3, 1] == 0); Assert.True(solvedBoard[3, 2] == BlackColor); Assert.True(solvedBoard[3, 3] == BlackColor); }
public void CrossoverTest() { //Arrange var boardA = BoardFactory.Create(rows, columns, 0.4); var boardB = BoardFactory.Create(rows, columns, 0.4); //Act var crossover = BoardFactory.Crossover(boardA, boardB, 1); //Assert Assert.AreEqual(boardA.Grid.Count, crossover.Grid.Count); Assert.AreEqual(boardA.Grid[0].Length, crossover.Grid[0].Length); }
public void CheckMovies_Start_Positions_Test() { //Arrange var boardFactory = new BoardFactory(); var chessboard = (ChessboardModel)boardFactory.Create(TypeOfGame.Chess); //Act var possibleMovies = chessboard["a2"].Piece.CheckStrategy.CheckMovies(new Position("a2"), chessboard); var actual = possibleMovies.Count(); //Assert Assert.AreEqual(2, actual); }
protected void Page_Load(object sender, EventArgs e) { if (game == null) { IBoardFactory boardFactory = new BoardFactory(); ITokenFactory tokenFactory = new TokenFactory(); game = new Game(boardFactory, tokenFactory); BoardRow0.BoardSpaceSelected += OnBoardSpaceSelected; BoardRow1.BoardSpaceSelected += OnBoardSpaceSelected; BoardRow2.BoardSpaceSelected += OnBoardSpaceSelected; } }
public void BlackPromotionStressUndoTest() { var board = BoardFactory.LoadBoardFromFen("1nbqkbnr/rppppppp/p7/8/1P6/P1P5/1p1PPPPP/R1BQKBNR b KQk - 0 3"); var original = board.CreateCopy(); var moves = board.GetMovesForPosition(BoardStateOffset.B2); foreach (var move in moves) { board.Move(move); board.UndoMove(move); everyThingIsEqual(original, board, move); } }
public void RunningEmptyGridTest() { //Arrange var board = BoardFactory.Create(rows, columns, 0); _game = new Game(board); //Act _game.Play(maxIterationToPlay); //Assert Assert.AreEqual(1, _game.Generation); }
public void IfAPlayerLandsOnGoToJailTheyGoToJail() { var jail = 10; var player = "Horse"; var players = new List<String> { player }; var banker = new Banker(players, 1500); var boardFactory = new BoardFactory(); var dice = new LoadedDice(); var guard = new PrisonGuard(banker, dice); var board = boardFactory.Create(banker, players, dice, guard); var goToJail = new GoToJail(board, jail, guard); goToJail.LandOnSpace(player); Assert.That(board.GetPosition(player), Is.EqualTo(10)); }
public void CannotSelectASquareOutOfRightBounds() { var board = default(IBoard); var squareSelectable = default(SquareSelectable); var result = default(bool); "Given I have a default 9x9 board".Context(() => { board = new BoardFactory().Create(); squareSelectable = new SquareSelectable(); }); "When I try to select a square out of bounds to the right".Do(() => result = squareSelectable.CanSelectSquare(board, 100, 3)); "Then that square should not be selectable".Observation(() => result.ShouldBeFalse()); }
public void CanFillAnEmptyBoard() { var numericalBoardFiller = default(NumericalBoardFiller); var board = default(Board); "Given that I have a board with with 41 selectable squares".Context(() => { numericalBoardFiller = new NumericalBoardFiller(); board = new BoardFactory().Create(); }); "When I fill the board".Do(() => numericalBoardFiller.Fill(board)); "Then every square that is not selectable should not contain a tile".Observation( () => board.AllSquares().Where(sq => !sq.IsSelectable && sq.HasTile).Count().ShouldEqual(0)); "Then every square that is selectable should contain a tile".Observation( () => board.AllSquares().Where(sq => sq.IsSelectable && sq.HasTile).Count().ShouldEqual(41)); }
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)); }
public void CanTellWhenTheAnimationShouldFinish() { var blocksFallingAnimation = default(BlocksFallingAnimation); "Given I have a standard board and a known list of coordinates".Context(() => { var board = new BoardFactory().Create(); var boardCoordinates = new List<BoardCoordinate> { new BoardCoordinate(1, 2), new BoardCoordinate(2, 3) }; board[1, 2].YOffset = 0; board[2, 3].YOffset = 0; blocksFallingAnimation = new BlocksFallingAnimation(boardCoordinates, board); }); "When I call animate when there are no more offsets to update" .Do(() => blocksFallingAnimation.Animate(new GameTime { ElapsedGameTime = TimeSpan.FromMilliseconds(100) })); "Then the animation should be finished" .Observation(() => blocksFallingAnimation.Finished().ShouldBeTrue()); }
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)); }
public void CanCorrectlyCalculateOriginForTopLeftSquareWhenCentreSquareSelected() { var result = default(Vector2); var board = default(IBoard); var squareOriginCalculator = default(SquareOriginCalculator); "Given I have a standard board with the centre square selected".Context(() => { board = new BoardFactory().Create(); squareOriginCalculator = new SquareOriginCalculator(board); board[4, 4].IsMainSelection = true; }); "When I calculate the origin for square 0, 0".Do( () => result = squareOriginCalculator.Calculate(board[0, 0])); "Then the origin x should be 180".Observation(() => result.X.ShouldEqual(180)); "Then the origin y should be 180".Observation(() => result.Y.ShouldEqual(180)); }
public void CanCorrectlyCalculateOriginForBottomRightSquareWhenSquareTwoOne() { var result = default(Vector2); var board = default(IBoard); var squareOriginCalculator = default(SquareOriginCalculator); "Given I have a standard board with the centre square selected".Context(() => { board = new BoardFactory().Create(); squareOriginCalculator = new SquareOriginCalculator(board); board[2, 1].IsMainSelection = true; }); "When I calculate the origin for square 8, 8".Do( () => result = squareOriginCalculator.Calculate(board[8, 8])); "Then the origin x should be -220".Observation(() => result.X.ShouldEqual(-220)); "Then the origin y should be -260".Observation(() => result.Y.ShouldEqual(-260)); }
public void RotatedLeftEventIsRaisedWhenIRotateASelectionLeft() { var selectionRotator = new SelectionRotatator(); var board = default(Board); var squareSelector = new SquareSelector(); var result = default(RotatedLeftEvent); "Given that I have a board filled alphabetically and I have selected the centre square".Context(() => { GameEvents.Dispatcher = new ActionEventDispatcher(a => result = a as RotatedLeftEvent); board = new BoardFactory().Create(); new NumericalBoardFiller().Fill(board); squareSelector.Select(board, 4, 4); }); "When I rotate the board left".Do(() => selectionRotator.Left(board)); "Then a rotated left event should be raised".Observation(() => result.ShouldNotBeNull()); "Then 16 squares should be in the event".Observation(() => result.BoardCoordinates.Count().ShouldEqual(16)); }
public void CanCorrectlyObtainAllSquaresPositonsWhenSquareTwoOneSelected() { var squarePositionCalculator = default(SquarePositionCalculator); var result = default(Vector2); "Given I have a standard board and have selected the centre square".Context(() => { var board = new BoardFactory().Create(); board[2, 1].IsMainSelection = true; squarePositionCalculator = new SquarePositionCalculator(board); }); "When I calculate the position for squares on the board".Do( () => result = squarePositionCalculator.Calculate()); "Then the X position should be 100 + board X margin".Observation( () => result.X.ShouldEqual(100 + DrawingConstants.Board.BOARD_X_MARGIN)); "Then the Y position should be 60 + board Y margin".Observation( () => result.Y.ShouldEqual(60 + DrawingConstants.Board.BOARD_Y_MARGIN)); }
public void CanSelectSquareFourAcrossTwoDownCorrectly() { SquareSelector squareSelector = default(SquareSelector); Board board = null; "Given I have a standard board with no squares selected and a square selector".Context(() => { board = new BoardFactory().Create(); squareSelector = new SquareSelector(); }); "When I select the centre square 4,2".Do(() => squareSelector.Select(board, 4, 2)); "Then square 4, 2 should be the main selection".Observation(() => board[4, 2].IsMainSelection.ShouldBeTrue()); "Then the square at position 4, 0 should be selected".Observation(() => board[4, 0].IsSelected.ShouldBeTrue()); "Then the square at position 4, 1 should be selected".Observation(() => board[4, 1].IsSelected.ShouldBeTrue()); "Then the square at position 4, 2 should be selected".Observation(() => board[4, 2].IsSelected.ShouldBeTrue()); "Then the square at position 4, 3 should be selected".Observation(() => board[4, 3].IsSelected.ShouldBeTrue()); "Then the square at position 4, 4 should be selected".Observation(() => board[4, 4].IsSelected.ShouldBeTrue()); "Then the square at position 2, 2 should be selected".Observation(() => board[2, 2].IsSelected.ShouldBeTrue()); "Then the square at position 3, 2 should be selected".Observation(() => board[3, 2].IsSelected.ShouldBeTrue()); "Then the square at position 5, 2 should be selected".Observation(() => board[5, 2].IsSelected.ShouldBeTrue()); "Then the square at position 6, 2 should be selected".Observation(() => board[6, 2].IsSelected.ShouldBeTrue()); "Then there should be a total of 9 selected squares".Observation( () => board.AllSquares().Count(sq => sq.IsSelected).ShouldEqual(9)); }
public void EachAnimationWillDecreaseTheAngle() { var board = default(IBoard); var rotateLeftAnimation = default(RotateLeftAnimation); "Given I have a standard board and a known list of coordinates".Context(() => { board = new BoardFactory().Create(); var boardCoordinates = new[] { new BoardCoordinate(1, 2), new BoardCoordinate(2, 3) }; rotateLeftAnimation = new RotateLeftAnimation(boardCoordinates, board); }); "When I call animate after 100 milliseconds has passed" .Do(() => rotateLeftAnimation.Animate(new GameTime { ElapsedGameTime = TimeSpan.FromMilliseconds(100) })); "Then the square at 1, 2 should be 90 - animation increase rate * 100".Observation( () => board[1, 2].Angle.ShouldEqual(90 - GameConstants.Animation.ANGLE_INCREASE_SPEED*100)); "Then the square at 2, 3 should be 90 - animation increase rate * 100".Observation( () => board[2, 3].Angle.ShouldEqual(90 - GameConstants.Animation.ANGLE_INCREASE_SPEED*100)); "Then 2 squares will have an angle other an 0".Observation( () => board.AllSquares().Count(sq => sq.Angle != 0).ShouldEqual(2)); }
public void CanSelectAnInBoundsSelectableSquare() { var board = default(IBoard); var squareSelectable = default(SquareSelectable); var result = default(bool); "Given I have a default 9x9 board".Context(() => { board = new BoardFactory().Create(); squareSelectable = new SquareSelectable(); }); "When I try to select a square in bounds that is selectable".Do(() => result = squareSelectable.CanSelectSquare(board, 3, 3)); "Then that square should be selectable".Observation(() => result.ShouldBeTrue()); }
public void LettersAreCorrectWhenIRotateASmallSelectionRight() { var selectionRotator = new SelectionRotatator(); var board = default(Board); var squareSelector = new SquareSelector(); "Given that I have a board filled alphabetically and I have selected square 5, 2".Context(() => { GameEvents.Dispatcher = new ActionEventDispatcher (a => { }); board = new BoardFactory().Create(); new NumericalBoardFiller().Fill(board); squareSelector.Select(board, 5, 2); }); "When I rotate the board right".Do(() => selectionRotator.Right(board)); "Then square 4, 1 will contain colour 3".Observation(() => board[4, 1].Colour.ShouldEqual(3)); "Then square 5, 1 will contain colour 7".Observation(() => board[5, 1].Colour.ShouldEqual(7)); "Then square 4, 2 will contain colour 14".Observation(() => board[4, 2].Colour.ShouldEqual(14)); "Then square 5, 2 will contain colour 8".Observation(() => board[5, 2].Colour.ShouldEqual(8)); "Then square 4, 3 will contain colour 13".Observation(() => board[4, 3].Colour.ShouldEqual(13)); "Then square 5, 3 will contain colour 9".Observation(() => board[5, 3].Colour.ShouldEqual(9)); "Then square 6, 3 will contain colour 15".Observation(() => board[6, 3].Colour.ShouldEqual(15)); "Then square 7, 3 will contain colour 16".Observation(() => board[7, 3].Colour.ShouldEqual(16)); }
public void CanRaiseARemoveFoundBlocksEventWhenAnimationHasFinished() { var blocksFoundAnimation = default(BlocksFoundAnimation); var result = default(IGameEvent); var board = default(IBoard); "Given I have a blocks found event with a number of blocks found" .Context(() => { var blocks = new[] { new Block(new[] {new BoardCoordinate(3, 3), new BoardCoordinate(3, 4)}) , new Block(new[] {new BoardCoordinate(5, 5), new BoardCoordinate(3, 4) }) }; board = new BoardFactory().Create(); var numericalBoardFiller = new NumericalBoardFiller(); numericalBoardFiller.Fill(board); blocksFoundAnimation = new BlocksFoundAnimation(blocks, board); GameEvents.Dispatcher = new ActionEventDispatcher(e => result = e); }); "When I call OnFinshed on the animation" .Do(() => blocksFoundAnimation.OnFinished()); "Then the event raised should be a remove found blocks event" .Observation(() => result.ShouldBeOfType<RemoveFoundBlocksEvent>()); "Then there should be 3 squares on the remove found blocks event" .Observation(() => ((RemoveFoundBlocksEvent) result).SquaresInBlocks .Count.ShouldEqual(3)); "Then there should be 1 square with cooardinates 3, 3" .Observation(() => ((RemoveFoundBlocksEvent) result).SquaresInBlocks .Count(c => c.X == 3 && c.Y == 3).ShouldEqual(1)); "Then there should be 1 square with cooardinates 3, 4" .Observation(() =>((RemoveFoundBlocksEvent)result).SquaresInBlocks .Count(c => c.X == 3 && c.Y == 4).ShouldEqual(1)); "Then there should be 1 square with cooardinates 5, 5" .Observation(() => ((RemoveFoundBlocksEvent)result).SquaresInBlocks .Count(c => c.X == 5 && c.Y == 5).ShouldEqual(1)); "Then there should be no squares in blocks" .Observation(() => board.AllSquares().Count(sq => sq.IsInBlock).ShouldEqual(0)); }
public void CanSetIsInBlockToTrueForAllSquares() { var board = default(IBoard); var blocksFoundAnimation = default(BlocksFoundAnimation); var blocks = default(IEnumerable<Block>); "Given I have a blocks found event with a number of blocks found" .Context(() => { board = new BoardFactory().Create(); var numericalBoardFiller = new NumericalBoardFiller(); numericalBoardFiller.Fill(board); blocks = new[] { new Block(new[] {new BoardCoordinate(3, 3), new BoardCoordinate(3, 4)}) , new Block(new[] {new BoardCoordinate(5, 5)}) }; }); "When I initiate the animation" .Do(() => blocksFoundAnimation = new BlocksFoundAnimation(blocks, board)); "Then the square at coordinate 3, 3 should be marked as in block" .Observation(() => board[3, 3].IsInBlock.ShouldBeTrue()); "Then the square at coordinate 3, 4 should be marked as in block" .Observation(() => board[3, 4].IsInBlock.ShouldBeTrue()); "Then the square at coordinate 5, 5 should be marked as in block" .Observation(() => board[5, 5].IsInBlock.ShouldBeTrue()); }
public void SetUp() { random = new Random(); dice = new Dice(random); player1 = "Horse"; player2 = "Car"; players = new List<String> { player1, player2 }; banker = new Banker(players, 1500); turns = new PlayerTurnCounter(players); var boardFactory = new BoardFactory(); guard = new PrisonGuard(banker, dice); board = boardFactory.Create(banker, players, dice, guard); game = new Game(players, dice, board, turns, guard); }
public void LettersAreCorrectWhenASelectionIsRotatedRight() { var selectionRotator = new SelectionRotatator(); var board = default(Board); var squareSelector = new SquareSelector(); "Given that I have a board filled numerically and I have selected the centre square".Context(() => { GameEvents.Dispatcher = new ActionEventDispatcher (a => { }); board = new BoardFactory().Create(); new NumericalBoardFiller().Fill(board); squareSelector.Select(board, 4, 4); }); "When I rotate the board right".Do(() => selectionRotator.Right(board)); "Then square 4, 0 will contain colour 17".Observation(() => board[4, 0].Colour.ShouldEqual(17)); "Then square 3, 1 will contain colour 2".Observation(() => board[3, 1].Colour.ShouldEqual(2)); "Then square 4, 1 will contain colour 18".Observation(() => board[4, 1].Colour.ShouldEqual(18)); "Then square 5, 1 will contain colour 4".Observation(() => board[5, 1].Colour.ShouldEqual(4)); "Then square 2, 2 will contain colour 5".Observation(() => board[2, 2].Colour.ShouldEqual(5)); "Then square 3, 2 will contain colour 6".Observation(() => board[3, 2].Colour.ShouldEqual(6)); "Then square 4, 2 will contain colour 19".Observation(() => board[4, 2].Colour.ShouldEqual(19)); "Then square 5, 2 will contain colour 8".Observation(() => board[5, 2].Colour.ShouldEqual(8)); "Then square 6, 2 will contain colour 9".Observation(() => board[6, 2].Colour.ShouldEqual(9)); "Then square 1, 3 will contain colour 10".Observation(() => board[1, 3].Colour.ShouldEqual(10)); "Then square 2, 3 will contain colour 11".Observation(() => board[2, 3].Colour.ShouldEqual(11)); "Then square 3, 3 will contain colour 12".Observation(() => board[3, 3].Colour.ShouldEqual(12)); "Then square 4, 3 will contain colour 20".Observation(() => board[4, 3].Colour.ShouldEqual(20)); "Then square 5, 3 will contain colour 14".Observation(() => board[5, 3].Colour.ShouldEqual(14)); "Then square 6, 3 will contain colour 15".Observation(() => board[6, 3].Colour.ShouldEqual(15)); "Then square 7, 3 will contain colour 16".Observation(() => board[7, 3].Colour.ShouldEqual(16)); "Then square 0, 4 will contain colour 41".Observation(() => board[0, 4].Colour.ShouldEqual(41)); "Then square 1, 4 will contain colour 39".Observation(() => board[1, 4].Colour.ShouldEqual(39)); "Then square 2, 4 will contain colour 35".Observation(() => board[2, 4].Colour.ShouldEqual(35)); "Then square 3, 4 will contain colour 29".Observation(() => board[3, 4].Colour.ShouldEqual(29)); "Then square 4, 4 will contain colour 21".Observation(() => board[4, 4].Colour.ShouldEqual(21)); "Then square 5, 4 will contain colour 13".Observation(() => board[5, 4].Colour.ShouldEqual(13)); "Then square 6, 4 will contain colour 7".Observation(() => board[6, 4].Colour.ShouldEqual(7)); "Then square 7, 4 will contain colour 3".Observation(() => board[7, 4].Colour.ShouldEqual(3)); "Then square 8, 4 will contain colour 1".Observation(() => board[8, 4].Colour.ShouldEqual(1)); "Then square 1, 5 will contain colour 26".Observation(() => board[1, 5].Colour.ShouldEqual(26)); "Then square 2, 5 will contain colour 27".Observation(() => board[2, 5].Colour.ShouldEqual(27)); "Then square 3, 5 will contain colour 28".Observation(() => board[3, 5].Colour.ShouldEqual(28)); "Then square 4, 5 will contain colour 22".Observation(() => board[4, 5].Colour.ShouldEqual(22)); "Then square 5, 5 will contain colour 30".Observation(() => board[5, 5].Colour.ShouldEqual(30)); "Then square 6, 5 will contain colour 31".Observation(() => board[6, 5].Colour.ShouldEqual(31)); "Then square 7, 5 will contain colour 32".Observation(() => board[7, 5].Colour.ShouldEqual(32)); "Then square 2, 6 will contain colour 33".Observation(() => board[2, 6].Colour.ShouldEqual(33)); "Then square 3, 6 will contain colour 34".Observation(() => board[3, 6].Colour.ShouldEqual(34)); "Then square 4, 6 will contain colour 23".Observation(() => board[4, 6].Colour.ShouldEqual(23)); "Then square 5, 6 will contain colour 36".Observation(() => board[5, 6].Colour.ShouldEqual(36)); "Then square 6, 6 will contain colour 37".Observation(() => board[6, 6].Colour.ShouldEqual(37)); "Then square 3, 7 will contain colour 38".Observation(() => board[3, 7].Colour.ShouldEqual(38)); "Then square 4, 7 will contain colour 24".Observation(() => board[4, 7].Colour.ShouldEqual(24)); "Then square 5, 7 will contain colour 40".Observation(() => board[5, 7].Colour.ShouldEqual(40)); "Then square 4, 8 will contain colour 25".Observation(() => board[4, 8].Colour.ShouldEqual(25)); }
public void CanCorrectlyCalculateTheOriginOfASquareWithAYOffset() { var result = default(Vector2); var board = default(IBoard); var squareOriginCalculator = default(SquareOriginCalculator); "Given I a y offset on square 0, 0".Context(() => { board = new BoardFactory().Create(); squareOriginCalculator = new SquareOriginCalculator(board); board[4, 4].IsMainSelection = true; board[0, 0].YOffset = 20; }); "When I calculate the origin for square 0, 0".Do( () => result = squareOriginCalculator.Calculate(board[0, 0])); "Then the origin x should be 180".Observation(() => result.X.ShouldEqual(180)); "Then the origin y should be 200".Observation(() => result.Y.ShouldEqual(200)); }
public void TheAnimationWillFinish() { var board = default(IBoard); var rotateLeftAnimation = default(RotateLeftAnimation); var gameTime = default(GameTime); "Given I set of squares in the board that need one more frame of animation".Context(() => { board = new BoardFactory().Create(); var boardCoordinates = new[] { new BoardCoordinate(1, 2), new BoardCoordinate(2, 3) }; rotateLeftAnimation = new RotateLeftAnimation(boardCoordinates, board); board[1, 2].Angle = 1; board[2, 3].Angle = 1; gameTime = new GameTime() { ElapsedGameTime = TimeSpan.FromMilliseconds(90 * GameConstants.Animation.ANGLE_INCREASE_SPEED + 1000) }; }); "When I call animate".Do(() => rotateLeftAnimation.Animate(gameTime)); "Then the square at 1, 2 should be 0".Observation( () => board[1, 2].Angle.ShouldEqual(0)); "Then the square at 2, 3 should be 0".Observation( () => board[2, 3].Angle.ShouldEqual(0)); "Then the animation should be finished".Observation(() => rotateLeftAnimation.Finished().ShouldBeTrue()); }
public void CanSelectTheCentreSquareCorrectly() { SquareSelector squareSelector = default(SquareSelector); Board board = null; "Given I have a standard board with no squares selected and a square selector".Context(() => { board = new BoardFactory().Create(); squareSelector = new SquareSelector(); }); "When I select the centre square".Do(() => squareSelector.Select(board, 4, 4)); "Then square 4, 4 should be the main selection".Observation(() => board[4, 4].IsMainSelection.ShouldBeTrue()); "Then the square at position 4, 0 should be selected".Observation(() => board[4, 0].IsSelected.ShouldBeTrue()); "Then the square at position 4, 1 should be selected".Observation(() => board[4, 1].IsSelected.ShouldBeTrue()); "Then the square at position 4, 2 should be selected".Observation(() => board[4, 2].IsSelected.ShouldBeTrue()); "Then the square at position 4, 3 should be selected".Observation(() => board[4, 3].IsSelected.ShouldBeTrue()); "Then the square at position 4, 4 should be selected".Observation(() => board[4, 4].IsSelected.ShouldBeTrue()); "Then the square at position 4, 5 should be selected".Observation(() => board[4, 5].IsSelected.ShouldBeTrue()); "Then the square at position 4, 6 should be selected".Observation(() => board[4, 6].IsSelected.ShouldBeTrue()); "Then the square at position 4, 7 should be selected".Observation(() => board[4, 7].IsSelected.ShouldBeTrue()); "Then the square at position 4, 8 should be selected".Observation(() => board[4, 8].IsSelected.ShouldBeTrue()); "Then the square at position 0, 4 should be selected".Observation(() => board[0, 4].IsSelected.ShouldBeTrue()); "Then the square at position 0, 4 should be selected".Observation(() => board[0, 4].IsSelected.ShouldBeTrue()); "Then the square at position 1, 4 should be selected".Observation(() => board[1, 4].IsSelected.ShouldBeTrue()); "Then the square at position 2, 4 should be selected".Observation(() => board[2, 4].IsSelected.ShouldBeTrue()); "Then the square at position 3, 4 should be selected".Observation(() => board[3, 4].IsSelected.ShouldBeTrue()); "Then the square at position 5, 4 should be selected".Observation(() => board[5, 4].IsSelected.ShouldBeTrue()); "Then the square at position 6, 4 should be selected".Observation(() => board[6, 4].IsSelected.ShouldBeTrue()); "Then the square at position 7, 4 should be selected".Observation(() => board[7, 4].IsSelected.ShouldBeTrue()); "Then the square at position 8, 4 should be selected".Observation(() => board[8, 4].IsSelected.ShouldBeTrue()); "Then there should be a total of 17 selected squares".Observation( () => board.AllSquares().Count(sq => sq.IsSelected).ShouldEqual(17)); }
private GameOfLife BuildGame(String rawData) { var inputTranslator = new InputTranslator(); var criteria = new GameCriteria { CellIterator = new CellIterator(), GameRules = new DefaultGameRules(), AliveValue = '*', DeadValue = '.' }; var boardFactory = new BoardFactory(new RowTranslator(criteria.AliveValue, criteria.DeadValue)); return new GameOfLife(rawData, criteria, inputTranslator, boardFactory); }
public void SquaresShouldContainNumbersInOrder() { var numericalBoardFiller = default(NumericalBoardFiller); var board = default(Board); "Given that I have a board with with 41 selectable squares".Context(() => { numericalBoardFiller = new NumericalBoardFiller(); board = new BoardFactory().Create(); }); "When I fill the board".Do(() => numericalBoardFiller.Fill(board)); "Then the 1st selectable square should contain the colour 1".Observation( () => board.AllSelectableSquaresWithTiles()[0].Colour.ShouldEqual(1)); "Then the 2nd selectable square should contain the colour 2".Observation( () => board.AllSelectableSquaresWithTiles()[1].Colour.ShouldEqual(2)); "Then the 3rd selectable square should contain the colour 3".Observation( () => board.AllSelectableSquaresWithTiles()[2].Colour.ShouldEqual(3)); "Then the 4th selectable square should contain the colour 4".Observation( () => board.AllSelectableSquaresWithTiles()[3].Colour.ShouldEqual(4)); "Then the 5th selectable square should contain the colour 5".Observation( () => board.AllSelectableSquaresWithTiles()[4].Colour.ShouldEqual(5)); "Then the 6th selectable square should contain the colour 6".Observation( () => board.AllSelectableSquaresWithTiles()[5].Colour.ShouldEqual(6)); "Then the 7tn selectable square should contain the colour 7".Observation( () => board.AllSelectableSquaresWithTiles()[6].Colour.ShouldEqual(7)); "Then the 8th selectable square should contain the colour 8".Observation( () => board.AllSelectableSquaresWithTiles()[7].Colour.ShouldEqual(8)); "Then the 9th selectable square should contain the colour 9".Observation( () => board.AllSelectableSquaresWithTiles()[8].Colour.ShouldEqual(9)); "Then the 10th selectable square should contain the colour 10".Observation( () => board.AllSelectableSquaresWithTiles()[9].Colour.ShouldEqual(10)); "Then the 11th selectable square should contain the colour 11".Observation( () => board.AllSelectableSquaresWithTiles()[10].Colour.ShouldEqual(11)); "Then the 12th selectable square should contain the colour 12".Observation( () => board.AllSelectableSquaresWithTiles()[11].Colour.ShouldEqual(12)); "Then the 13th selectable square should contain the colour 13".Observation( () => board.AllSelectableSquaresWithTiles()[12].Colour.ShouldEqual(13)); "Then the 14th selectable square should contain the colour 14".Observation( () => board.AllSelectableSquaresWithTiles()[13].Colour.ShouldEqual(14)); "Then the 15th selectable square should contain the colour 15".Observation( () => board.AllSelectableSquaresWithTiles()[14].Colour.ShouldEqual(15)); "Then the 16th selectable square should contain the colour 16".Observation( () => board.AllSelectableSquaresWithTiles()[15].Colour.ShouldEqual(16)); "Then the 17th selectable square should contain the colour 17".Observation( () => board.AllSelectableSquaresWithTiles()[16].Colour.ShouldEqual(17)); "Then the 18th selectable square should contain the colour 18".Observation( () => board.AllSelectableSquaresWithTiles()[17].Colour.ShouldEqual(18)); "Then the 19th selectable square should contain the colour 19".Observation( () => board.AllSelectableSquaresWithTiles()[18].Colour.ShouldEqual(19)); "Then the 20th selectable square should contain the colour 20".Observation( () => board.AllSelectableSquaresWithTiles()[19].Colour.ShouldEqual(20)); "Then the 21st selectable square should contain the colour 21".Observation( () => board.AllSelectableSquaresWithTiles()[20].Colour.ShouldEqual(21)); "Then the 22nd selectable square should contain the colour 22".Observation( () => board.AllSelectableSquaresWithTiles()[21].Colour.ShouldEqual(22)); "Then the 23rd selectable square should contain the colour 23".Observation( () => board.AllSelectableSquaresWithTiles()[22].Colour.ShouldEqual(23)); "Then the 24th selectable square should contain the colour 24".Observation( () => board.AllSelectableSquaresWithTiles()[23].Colour.ShouldEqual(24)); "Then the 25th selectable square should contain the colour 25".Observation( () => board.AllSelectableSquaresWithTiles()[24].Colour.ShouldEqual(25)); "Then the 26th selectable square should contain the colour 26".Observation( () => board.AllSelectableSquaresWithTiles()[25].Colour.ShouldEqual(26)); "Then the 27th selectable square should contain the colour 27".Observation( () => board.AllSelectableSquaresWithTiles()[26].Colour.ShouldEqual(27)); "Then the 28th selectable square should contain the colour 28".Observation( () => board.AllSelectableSquaresWithTiles()[27].Colour.ShouldEqual(28)); "Then the 29th selectable square should contain the colour 29".Observation( () => board.AllSelectableSquaresWithTiles()[28].Colour.ShouldEqual(29)); "Then the 30th selectable square should contain the colour 30".Observation( () => board.AllSelectableSquaresWithTiles()[29].Colour.ShouldEqual(30)); "Then the 31st selectable square should contain the colour 31".Observation( () => board.AllSelectableSquaresWithTiles()[30].Colour.ShouldEqual(31)); "Then the 32nd selectable square should contain the colour 32".Observation( () => board.AllSelectableSquaresWithTiles()[31].Colour.ShouldEqual(32)); "Then the 33rd selectable square should contain the colour 33".Observation( () => board.AllSelectableSquaresWithTiles()[32].Colour.ShouldEqual(33)); "Then the 34th selectable square should contain the colour 34".Observation( () => board.AllSelectableSquaresWithTiles()[33].Colour.ShouldEqual(34)); "Then the 35th selectable square should contain the colour 35".Observation( () => board.AllSelectableSquaresWithTiles()[34].Colour.ShouldEqual(35)); "Then the 36th selectable square should contain the colour 36".Observation( () => board.AllSelectableSquaresWithTiles()[35].Colour.ShouldEqual(36)); "Then the 37th selectable square should contain the colour 37".Observation( () => board.AllSelectableSquaresWithTiles()[36].Colour.ShouldEqual(37)); "Then the 38th selectable square should contain the colour 38".Observation( () => board.AllSelectableSquaresWithTiles()[37].Colour.ShouldEqual(38)); "Then the 39th selectable square should contain the colour 39".Observation( () => board.AllSelectableSquaresWithTiles()[38].Colour.ShouldEqual(39)); "Then the 40th selectable square should contain the colour 40".Observation( () => board.AllSelectableSquaresWithTiles()[39].Colour.ShouldEqual(40)); "Then the 41st selectable square should contain the colour 41".Observation( () => board.AllSelectableSquaresWithTiles()[40].Colour.ShouldEqual(41)); }