import XCTest @testable import Model final class EmptyBoardTests: XCTestCase { private var board: Board! override func setUp() { super.setUp() guard let board = Board(columns: 5, rows: 6) else { XCTFail() return } self.board = board } func testWidth() throws { XCTAssertEqual(board.columns, 5) } func testHeight() throws { XCTAssertEqual(board.rows, 6) } func testEmptyByDefault() throws { XCTAssertNil(board[1, 1]) let result = board.countPieces() XCTAssertEqual(result.a, 0) XCTAssertEqual(result.b, 0) } func testSetGet() throws { board[1, 1] = Piece.Player1; XCTAssertEqual(board[1, 1], .Player1) } func testCounts() throws { board[1, 2] = .Player2 let counts = board.countPieces() XCTAssertEqual(counts.a, 0) XCTAssertEqual(counts.b, 1) } func testInsertTopNoPush() { XCTAssert(board.insert(piece: .Player1, side: .Top, offset: 2)) XCTAssertEqual(board[2, 0], .Player1) } func testInsertBottomNoPush() { XCTAssert(board.insert(piece: .Player2, side: .Bottom, offset: 2)) XCTAssertEqual(board[2, board.rows - 1], .Player2) } func testInsertLeftNoPush() { XCTAssert(board.insert(piece: .Player1, side: .Left, offset: 2)) XCTAssertEqual(board[0, 2], .Player1) } func testInsertRightNoPush() { XCTAssert(board.insert(piece: .Player2, side: .Right, offset: 2)) XCTAssertEqual(board[board.columns - 1, 2], .Player2) } }