require "runit/testcase"
require 'runit/cui/testrunner'

require "braingame"

class Test < RUNIT::TestCase
	def test_init
		puts ""
		g = GameBoard.new
		puts g
	end

	def test_rotate
		puts ""
		g = GameBoard.new
		g.click(2,2)
		assert_equals 1,g.board[2][2]
		assert_equals 1,g.board[1][2]
		assert_equals 1,g.board[2][1]
		assert_equals 1,g.board[3][2]
		assert_equals 1,g.board[2][3]
		puts "Click(2,2)\n#{g}"
		g.click(1,2)
		assert_equals 2,g.board[1][2]
		assert_equals 2,g.board[2][2]
		assert_equals 1,g.board[0][2]
		assert_equals 0,g.board[0][1]
		puts "Click(1,2)\n#{g}"
	end

	def test_scramble
		puts ""
		g = GameBoard.new
		g.scramble
		puts g
	end

	def test_undo
		puts ""
		g = GameBoard.new
		g.scramble
		g1 = g.to_s
		puts "Scramble:\n#{g1}"
		g.click(2,2)
		g2 = g.to_s
		puts "Click(2,2):\n#{g2}"
		g.undo
		g3 = g.to_s
		puts "Undo:\n#{g3}"
		assert_equals g1,g3
	end
end

RUNIT::CUI::TestRunner.run(Test.suite)
