I'm trying to write unit tests for an application that reports on Entries in an EventLog. Right now when I run the unit tests, I'm having to create a temporary EventLog, write entries to it, and delete the log when I'm done. I'm doing this because I need to get back the EventLogEntry object, which have no constructor.
My question is are there any ways of mocking an EventLog to be able to get back EventLogEntries. Having to write entries to the actual EventLog seems more like integration testing than unit testing to me.
You would be correct that this is more of an integration test. However you need to ask yourself what you are really trying to test here. If it is truly a unit test, and you only want to test the logic over your EventLogEntries, then you should treat the event log like any other external dependency.
TDD has lead me down the road of isolating and mocking many things that feel strange to mock, but have ended up saving me from maintenance nightmares later on. i.e. File IO, Logging, Tracing, etc...
I would stick all your CRUD operations to the event log behind an interface boundary and treat it as if it were data access. If you can't easily create EventLogEntries out of band, then you might even consider creating your own entities that represent entries from the event log and use them.