def test_with_handler(self, mocker, pipeline, message):
        # Set the handler
        mock_handler = mocker.MagicMock()
        pipeline.on_c2d_message_received = mock_handler
        assert mock_handler.call_count == 0

        # Create the event
        c2d_event = pipeline_events_iothub.C2DMessageEvent(message)

        # Trigger the event
        pipeline._pipeline.on_pipeline_event_handler(c2d_event)

        assert mock_handler.call_count == 1
        assert mock_handler.call_args == mocker.call(message)
 def test_no_handler(self, pipeline, message):
     c2d_event = pipeline_events_iothub.C2DMessageEvent(message)
     pipeline._pipeline.on_pipeline_event_handler(c2d_event)