VahidN / EFSecondLevelCache.Core

Entity Framework Core Second Level Caching Library
Apache License 2.0
326 stars 51 forks source link

How To Mock Or Config EFSecondLevelCache.Core In Unit Testing? #35

Closed MohsenKasraeifar closed 5 years ago

MohsenKasraeifar commented 5 years ago

Summary of the issue

When we use EFSecondLevelCache.Core for for caching query, and write a test for these methods, get an exception in saveChange.

Exception:

Unable to resolve service for type 'EFSecondLevelCache.Core.Contracts.IEFCacheServiceProvider'. This is often because no database provider has been configured for this DbContext. A provider can be configured by overriding the DbContext.OnConfiguring method or by using AddDbContext on the application service provider. If AddDbContext is used, then also ensure that your DbContext type accepts a DbContextOptions<TContext> object in its constructor and passes it to the base constructor for DbContext.

Is there a way for mocked or inject config EFSecondLevelCache.Core in unit testing?

VahidN commented 5 years ago

It's duplicate of #https://github.com/VahidN/EFSecondLevelCache.Core/issues/31

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related problems.