# :nodoc: all require "test/unit" require "nitro/events" class TC_Events < Test::Unit::TestCase # :nodoc: all include N def setup $flag = 0 $flag2 = 1 @events = N::EventManager.new end def teardown @events = nil end def test_events @events.add_handler("my.event", "test1", proc { |val| $flag = val }) @events.add_handler("my.event", "test2", proc { |val| $flag2 += val }) @events.fire("my.event", 5) assert_equal(5, $flag) assert_equal(6, $flag2) @events.fire("my.event", 5) assert_equal(11, $flag2) # test remove handler @events.remove_handler("my.event", "test2") @events.fire("my.event", 5) assert_equal(11, $flag2) end end