1
votes

I'm a bit confused about the use of the ILoggerFactory interface in .NET Core.

In my integration test I need to new up a MemcachedClientConfiguration object, which insists on a ILoggerFactory parameter.

In the articles and examples I've seen, it looks like ILoggerFactory is automatically injected as a dependency in .NET core. But how would I know what implementation of ILoggerFactory to new up in my integration test?

Clearly there's something missing in my understanding, as whenever I've injected interfaces before I've always had to declare and register them in my IOC class (coming from .NET framework). If I wanted to use a third party logging library like log4net, how would I feed this in to MemcachedClientConfiguration?

1
In your integration tests, do you really need a concrete implementation of ILoggerFactory or would a mock be enough? - Kzrystof
I was under the assumption integration tests should not use mocks but I see your point, as logging as nothing to do with the behaviour under test, I don't see any problem with this approach. - FBryant87

1 Answers

0
votes

As mentioned the comments, this specific case may not require you to provide a concrete implementation of an ILoggerFactory. A simple mock can be enough for the integration tests.