Sha256: 3bd41d22028f3714e81da56240c3c102501f4cb74563c01557e1eb0733bd43e0

Contents?: true

Size: 1.4 KB

Versions: 7

Compression:

Stored size: 1.4 KB

Contents

$:.unshift File.join(File.dirname(__FILE__),'..','lib')

require 'test/unit'
#require 'rhcp/dispatching_broker'
#require 'rhcp/broker'
#require 'rhcp/command'
#require 'rhcp/command_param'
require 'rhcp'

class DispatchingBrokerTest < Test::Unit::TestCase
  
  def setup
    @broker1 = RHCP::Broker.new()
    @broker1.register_command RHCP::Command.new("test", "just testing (broker1)", lambda{})
    @broker1.register_command RHCP::Command.new("test_more", "another fancy command from broker1", lambda{})
    @broker2 = RHCP::Broker.new()
    @broker2.register_command RHCP::Command.new("echo", "says hello (broker2)", lambda{})
    @broker2.register_command RHCP::Command.new("help", "is no help at all (broker2)", lambda{})
    @broker2.register_command RHCP::Command.new("red button", "don't press it (broker2)", lambda{})
  end
  
  def test_add_brokers
    dispatcher = RHCP::DispatchingBroker.new()
    assert_not_nil dispatcher
    assert_equal 0, dispatcher.get_command_list.size
    dispatcher.add_broker(@broker1)
    assert_equal 2, dispatcher.get_command_list.size
    dispatcher.add_broker(@broker2)    
    assert_equal 5, dispatcher.get_command_list.size
  end
  
  def test_duplicate_commands
    dispatcher = RHCP::DispatchingBroker.new()
    dispatcher.add_broker(@broker1)
    assert_equal 2, dispatcher.get_command_list.size
    assert_raise(RHCP::RhcpException) { dispatcher.add_broker(@broker1) }
  end
  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rhcp-0.1.2 test/rhcp/dispatching_broker_test.rb
rhcp-0.1.4 test/rhcp/dispatching_broker_test.rb
rhcp-0.1.5 test/rhcp/dispatching_broker_test.rb
rhcp-0.1.6 test/rhcp/dispatching_broker_test.rb
rhcp-0.1.7 test/rhcp/dispatching_broker_test.rb
rhcp-0.1.8 test/rhcp/dispatching_broker_test.rb
rhcp-0.1.9 test/rhcp/dispatching_broker_test.rb