Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs

Dashboard
Notifications
Mark all as read
Q&A

How to mock LazyCache when performing unit testing?

+0
−0

A few of my services rely on LazyCache and they use it by injecting IAppCache.

For unit testing, I would like to mock this. I have found MockCachingService, but it does not do any caching (as specified in the comments).

What is the way to perform unit testing in this scenario?

Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

How else? (1 comment)

1 answer

+0
−0

LazyCache provides CachingService as a concrete implementation of the IAppCache.

When unit testing simply instantiate the tested service using CachingService:

var testInstance = new FooService(new CachingService());
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »