def assertTriggerDispatched(self, trigger, payload=None, trace_context=None):
        """
        Assert that the trigger with the provided values has been dispatched.

        :param trigger: Name of the trigger.
        :type trigger: ``str``

        :param paylod: Trigger payload (optional). If not provided, only trigger name is matched.
        type: payload: ``object``

        :param trace_context: Trigger trace context (optional). If not provided, only trigger name
                              is matched.
        type: payload: ``object``
        """
        dispatched_triggers = self.get_dispatched_triggers()
        for item in dispatched_triggers:
            trigger_matches = item["trigger"] == trigger

            if payload:
                payload_matches = item["payload"] == payload
            else:
                payload_matches = True

            if trace_context:
                trace_context_matches = item["trace_context"] == trace_context
            else:
                trace_context_matches = True

            if trigger_matches and payload_matches and trace_context_matches:
                return True

        msg = 'Trigger "%s" hasn\'t been dispatched' % (trigger)
        raise AssertionError(msg)

        Assert that the trigger with the provided values has been dispatched.

        :param trigger: Name of the trigger.
        :type trigger: ``str``

        :param paylod: Trigger payload (optional). If not provided, only trigger name is matched.
        type: payload: ``object``

        :param trace_context: Trigger trace context (optional). If not provided, only trigger name
                              is matched.
        type: payload: ``object``
        
st2tests/st2tests/sensors.py