arcus-azure / arcus.eventgrid

Azure Event Grid development in a breeze
https://eventgrid.arcus-azure.net/
MIT License
17 stars 6 forks source link

Provide support to filter based on event payload for writing automated tests #178

Closed tomkerkhove closed 3 years ago

tomkerkhove commented 3 years ago

What feature would you like to have? Provide support to filter based on event payload for writing automated tests instead of relying on the event ID.

stijnmoreels commented 3 years ago

Would this filter mean that you could filter on the typed CloudEvent/EventGridEvent payloads? Or only the event itself. Maybe some context here could be helpful, where you could encountered the opportunity.

tomkerkhove commented 3 years ago

Now you can do the following:

var rawReceivedEvent = _eventConsumerHost.GetReceivedEvent(eventId, timeout.Value);

But instead, I'd like to filter on one of the following things:

So giving us a func that gives us the CloudEvent and allows us to return true or false.

var rawReceivedEvent = _eventConsumerHost.GetReceivedEvent(cloudEvent => cloudEvent.Subject.Contains("my-id"), timeout.Value);

But next to that I'd like to be able to have a func which gives me the deserialized data payload on which I can work.

var rawReceivedEvent = _eventConsumerHost.GetReceivedEvent<OrderCreatedEvent>(orderCreatedEvent => orderCreatedEvent.OrderId == ("my-order-id"), timeout.Value);
stijnmoreels commented 3 years ago

Ok, that we can do! Maybe, in this case, you also want to get a set of events, as the filter could not always be referencing to a unique event?

tomkerkhove commented 3 years ago

For us it is aimed for single events at the moment, but who knows 🤷‍♂️

stijnmoreels commented 3 years ago

For us it is aimed for single events at the moment, but who knows 🤷‍♂️

Aha, ok, bc you may get false positives when receiving on something that's available for multiple events.

tomkerkhove commented 3 years ago

That's certainly possible, but with great filtering power comes great responsibilities :D