anchor.diff:      ].
   
   
  +test_poll_device_event() ->
  +    meck:new( lurch_driver_port, [] ),
  +    Token = make_ref(),
  +    meck:expect( lurch_driver_port, request_event_async,
  +                 fun( _, _ ) -> Token end ),
  +    DeviceId = make_ref(),
  +    Event = myevent,
  +    Device = #device{ id = DeviceId, events = [ Event ] },
  +    S0 = #state{ devices = orddict:store( DeviceId, Device, orddict:new() )
  +               , polls = [] },
  +
  +    { noreply, S1 } = handle_cast( { poll_device_event, DeviceId, Event }, S0 ),
  +    { noreply, S2 } = handle_cast( { poll_device_event, invalid, Event }, S0 ),
  +    { noreply, S3 } = handle_cast( { poll_device_event, DeviceId, invalid }, S0 ),
  +
  +    [ { "valid device and event", ?_assertEqual( [ Token ], S1#state.polls ) }
  +    , { "invalid device", ?_assertEqual( S0, S2 ) }
  +    , { "invalid event", ?_assertEqual( S0, S3 ) }
  +    ].
  +
  +
   % Helper functions
  -test_poll_device_event( Pid ) ->
  -    { ok, DeviceId } = start_device( Pid, dummy_driver_config( ) ),
  -    InvalidDeviceId = make_ref(),
  -    InvalidEvent = <<"non_existing_event">>,
  -    Res1 = poll_device_event( Pid, DeviceId, ?EVENT_NAME ),
  -    Res2 = poll_device_event( Pid, InvalidDeviceId, ?EVENT_NAME ),
  -    Res3 = poll_device_event( Pid, DeviceId, InvalidEvent ),
  -    [ { "poll event", ?_assertEqual( { ok, <<"dummy">> }, Res1 ) }
  -    , { "bad device", ?_assertEqual( { error, no_such_device }, Res2 ) }
  -    , { "bad event", ?_assertEqual( { error, no_such_event }, Res3 ) }
  -    ].
  -
  -
  -
   dummy_driver_config( ) ->
       [ { driver, ?DRIVER_NAME }
       , { parameters, [] }
  
positive.code:                             , parameters = Parameters
                              , events = Events
                              , pid = Pid },
              Devices = orddict:store( Device#device.id, Device, State#state.devices ),
              NewState = State#state{ devices = Devices },
              { reply, { ok, Device#device.id }, NewState };
          { error, _ } = Error ->
  
negative.code:                  fun( _Driver, _Parameters ) -> { error, enoent } end ),
      StartResult = start_device( Pid, dummy_driver_config( ) ),
      [ { "error propagated", ?_assertMatch( { error, _Error }, StartResult ) } ].
  
  
  test_add_list_devices( Pid ) ->
  