test/test_notifyhub.rb in notifyhub-0.0.2 vs test/test_notifyhub.rb in notifyhub-0.0.3
- old
+ new
@@ -1,59 +1,17 @@
require 'test/unit'
require 'notifyhub'
-# # Create class that includes interesting events.
-# class Storage
-#
-# # Handle to NotifyHub.
-# attr_accessor :hub
-#
-# def initialize
-# # Create NotifyHub.
-# @hub = NotifyHub.declare( :store, :load, :na )
-# end
-#
-# # Store data and notify clients.
-# def store( data )
-# @data = data
-# @hub[ :store ].notify( @data )
-# end
-#
-# # Load data and notify clients.
-# def load
-# @hub[ :load ].notify( @data )
-# @data
-# end
-# end
-#
-#
-# storage = Storage.new
-#
-# # Setup notify action for store.
-# storage.hub[ :store ].action do |data|
-# puts "store: #{data}"
-# end
-#
-# # Setup notify action for load.
-# storage.hub[ :load ].action do |data|
-# puts "load: #{data}"
-# end
-#
-#
-# # Use storage and get notifications.
-# storage.store( "my data" )
-# data = storage.load
-
class NotifyHubTest < Test::Unit::TestCase
-
+
# Create class that includes interesting events.
class Storage
# Handle to NotifyHub.
attr_accessor :hub
-
+
def initialize
# Create NotifyHub.
@hub = NotifyHub.declare( :store, :load, :na )
end
@@ -73,11 +31,11 @@
def setup
@check = {}
@n = NotifyHub.auto
-
+
@n[ :on ].action do |val|
@check[ :create_1 ] = val
end
@n[ :on ].action do |val|
@@ -138,11 +96,11 @@
end
n[ :off ].action do |val|
@check[ :create_3 ] = val
end
-
+
n[ :on ].notify( 1 )
n.notify( :off, 2 )
assert_equal( 1, @check[ :create_1 ] )
assert_equal( 1, @check[ :create_2 ] )
@@ -181,11 +139,11 @@
@n[ :on ].notify( 1 )
@n[ :off ].notify( 2 )
assert_equal( 1, @check[ :create_1 ] )
assert_equal( 1, @check[ :create_2 ] )
- assert_equal( 2, @check[ :create_3 ] )
+ assert_equal( 2, @check[ :create_3 ] )
end
def test_remove
@n[ :on ].remove( @n[ :on ][ 0 ] )
@@ -223,7 +181,13 @@
@check[ :error_redecl ] = true
end
assert_equal( true, @check[ :error_redecl ] )
end
+
+
+ def test_ids
+ assert_equal( [ :on, :off ], @n.ids )
+ end
+
end