1 # Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
9 require 'board/square_tag'
10 require 'board/point_converter'
14 class FakeTaggableBoard
15 include PointConverter
16 include TaggableSquares
21 def method_missing(m, *args)
39 class TestSquareTag < Test::Unit::TestCase
41 @board = FakeTaggableBoard.new
45 assert @board.respond_to?(:selection)
46 assert @board.respond_to?(:selection=)
49 def test_empty_initial_tag
50 assert_nil @board.selection
53 def test_set_retrieve_tag
54 @board.expects(:add_item).with do |name, pix, args|
55 name == :selection and args[:pos] == Point.new(30.0, 20.0)
57 @board.selection = Point.new(3, 2)
58 assert_equal Point.new(3, 2), @board.selection
61 def test_set_cancel_tag
62 @board.expects(:add_item).with do |name, pix, args|
63 name == :selection and args[:pos] == Point.new(50.0, 30.0)
65 @board.expects(:remove_item).with(:selection)
67 @board.selection = Point.new(5, 3)
68 @board.selection = nil
69 assert_nil @board.selection