Changeset 193

Show
Ignore:
Timestamp:
11/20/04 01:51:04 (4 years ago)
Author:
ged
Message:

-- Added tests for event reflection

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/simplest-thing/tests/area.tests.rb

    r172 r193  
    1919 
    2020require 'fm/area' 
     21require 'fm/event' 
     22require 'fm/entity' 
    2123 
    2224### Test case for the FaerieMUD::Area class and associated classes/modules. 
    2325class FaerieMUD::AreaTestCase < FaerieMUD::TestCase 
     26 
     27    class PingEvent < FaerieMUD::Event; end 
     28    class PingVerb < FaerieMUD::Verb; end 
     29 
     30    class TestLocus < FaerieMUD::Locus 
     31        def initialize( args={} ) 
     32            super 
     33            @pingEchoCount = 0 
     34        end 
     35 
     36        attr_reader :pingEchoCount 
     37 
     38        def ping 
     39            ev = PingEvent::new( 
     40                :instigator => self, 
     41                :origin => self, 
     42                :verb => PingVerb::instance 
     43                ) 
     44            self.disperseEvents( ev ) 
     45        end 
     46 
     47        def handlePingEvent( ev ) 
     48            @pingEchoCount += 1 
     49        end 
     50    end 
     51 
    2452 
    2553    ################################################################# 
     
    2957    ### Instance test 
    3058    def test_00_Instance 
     59        printTestHeader "Area: Instance" 
    3160        rval = nil 
    3261 
     
    4170        } 
    4271    end 
    43      
     72 
     73 
     74    ### Reflect dispersed events back into the area's contents 
     75    def test_10_reflect_events 
     76        printTestHeader "Area: Reflect dispersed events" 
     77 
     78        tl = TestLocus::new 
     79        area = FaerieMUD::Area::new 
     80        area << tl 
     81         
     82        # Ping -- should get an echo back 
     83        assert_nothing_raised { tl.ping } 
     84        assert_equal 1, tl.pingEchoCount 
     85 
     86        assert_nothing_raised { tl.ping } 
     87        assert_equal 2, tl.pingEchoCount 
     88 
     89    end 
    4490end 
    4591