public void GetAgainDoesNotIncreaseCount() { BoardCache boardCache = new BoardCache(10); const int TestSize = 10; HexBoard[] usedBoards = new HexBoard[TestSize]; // add some boards for (int i = 0; i < TestSize; i++) { usedBoards[i] = boardCache.GetBoard(); } // remove them for (int i = 0; i < TestSize; i++) { boardCache.Release(usedBoards[i]); } // get again, count should not change since there are now boards ready to use for (int i = 0; i < TestSize; i++) { usedBoards[i] = boardCache.GetBoard(); Assert.IsNotNull(usedBoards[i]); Assert.AreEqual(TestSize, boardCache.BoardCount); } }
public void CreateIsEmptyCache() { BoardCache boardCache = new BoardCache(10); // empty cache Assert.IsNotNull(boardCache); Assert.AreEqual(0, boardCache.BoardCount); }
public Minimax(HexBoard board, GoodMoves goodMoves, ICandidateMoves candidateMovesFinder) { this.actualBoard = board; this.goodMoves = goodMoves; this.candidateMovesFinder = candidateMovesFinder; this.boardCache = new BoardCache(board.Size); this.pathLengthFactory = new PathLengthAStarFactory(); }
public void AddBoardIncreasesCount() { BoardCache boardCache = new BoardCache(10); const int TestSize = 10; HexBoard[] usedBoards = new HexBoard[TestSize]; // add some boards for (int i = 0; i < TestSize; i++) { usedBoards[i] = boardCache.GetBoard(); Assert.IsNotNull(usedBoards[i]); Assert.AreEqual(i + 1, boardCache.BoardCount); } }
public void ReleaseBoardIncreasesCount() { BoardCache boardCache = new BoardCache(10); const int TestSize = 10; HexBoard[] usedBoards = new HexBoard[TestSize]; // add some boards for (int i = 0; i < TestSize; i++) { usedBoards[i] = boardCache.GetBoard(); } // remove them for (int i = 0; i < TestSize; i++) { boardCache.Release(usedBoards[i]); // count doesn't go down Assert.AreEqual(TestSize, boardCache.BoardCount); Assert.AreEqual(i + 1, boardCache.AvailableCount); } }