I've got an Apex class with simple method returning recently viewed records using 'RecentlyViewed' object type. The issue is with inserting test data for unit tests because LastViewedDate field is not writeable so I can't mark my test records as recently viewed.
Do you have idea how to workaround this problem? Is there a trick to mark records as recently viewed via apex code? Or do I have to simply view several records in my Salesforce App and then hardcode their Id in my test method?
SeeAllData
to be enabled and would also require that data exist in the org.