Background: I have a method that runs in before insert context on Cases. It looks for Cases that were created via standard Email-to-Case functionality when sent to a specific routing address. It parses out some of the info from the text body of the email and populates Case field values based on that info.
Problem: I'm struggling with how to get this covered in a test class. I want to mimic the Email-to-Case functionality to create the Case, as my code queries info from the EmailMessage object to match it to the correct Case and then set the Case field values.
TL;DR: How can I, in a test class, send an email to a specified address and have it create a Case via standard Email-to-Case?