Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Refactored Cache Settings

support2a3a64977f1f
diff --git a/src/Core/Grand.Infrastructure/Caching/MemoryCacheBase.cs b/src/Core/Grand.Infrastructure/Caching/MemoryCacheBase.cs
index 5300477d6..5763ff84b 100644
--- a/src/Core/Grand.Infrastructure/Caching/MemoryCacheBase.cs
+++ b/src/Core/Grand.Infrastructure/Caching/MemoryCacheBase.cs
@@ -1,5 +1,5 @@
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Events;
-using Grand.SharedKernel.Extensions;
using MediatR;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Primitives;
@@ -16,7 +16,8 @@ namespace Grand.Infrastructure.Caching
private readonly IMemoryCache _cache;
private readonly IMediator _mediator;
-
+ private readonly CacheConfig _cacheConfig;
+
private bool _disposed;
private static CancellationTokenSource _resetCacheToken = new();
@@ -26,10 +27,11 @@ namespace Grand.Infrastructure.Caching
#region Ctor
- public MemoryCacheBase(IMemoryCache cache, IMediator mediator)
+ public MemoryCacheBase(IMemoryCache cache, IMediator mediator, CacheConfig cacheConfig)
{
_cache = cache;
_mediator = mediator;
+ _cacheConfig = cacheConfig;
}
#endregion
@@ -38,7 +40,7 @@ namespace Grand.Infrastructure.Caching
public virtual Task<T> GetAsync<T>(string key, Func<Task<T>> acquire)
{
- return GetAsync(key, acquire, CommonHelper.CacheTimeMinutes);
+ return GetAsync(key, acquire, _cacheConfig.DefaultCacheTimeMinutes);
}
public virtual async Task<T> GetAsync<T>(string key, Func<Task<T>> acquire, int cacheTime)
@@ -63,7 +65,7 @@ namespace Grand.Infrastructure.Caching
public virtual T Get<T>(string key, Func<T> acquire)
{
- return Get(key, acquire, CommonHelper.CacheTimeMinutes);
+ return Get(key, acquire, _cacheConfig.DefaultCacheTimeMinutes);
}
public virtual T Get<T>(string key, Func<T> acquire, int cacheTime)
diff --git a/src/Core/Grand.Infrastructure/Caching/RabbitMq/RabbitMqMessageCacheManager.cs b/src/Core/Grand.Infrastructure/Caching/RabbitMq/RabbitMqMessageCacheManager.cs
index e24801bed..7139eff01 100644
--- a/src/Core/Grand.Infrastructure/Caching/RabbitMq/RabbitMqMessageCacheManager.cs
+++ b/src/Core/Grand.Infrastructure/Caching/RabbitMq/RabbitMqMessageCacheManager.cs
@@ -1,4 +1,5 @@
using Grand.Infrastructure.Caching.Message;
+using Grand.Infrastructure.Configuration;
using MassTransit;
using MediatR;
using Microsoft.Extensions.Caching.Memory;
@@ -11,8 +12,8 @@ namespace Grand.Infrastructure.Caching.RabbitMq
private readonly IMemoryCache _cache;
private readonly IBus _bus;
- public RabbitMqMessageCacheManager(IMemoryCache cache, IMediator mediator, IBus bus)
- : base(cache, mediator)
+ public RabbitMqMessageCacheManager(IMemoryCache cache, IMediator mediator, IBus bus, CacheConfig config)
+ : base(cache, mediator, config)
{
_cache = cache;
_bus = bus;
diff --git a/src/Core/Grand.Infrastructure/Caching/Redis/RedisMessageCacheManager.cs b/src/Core/Grand.Infrastructure/Caching/Redis/RedisMessageCacheManager.cs
index a45914902..1b906370f 100644
--- a/src/Core/Grand.Infrastructure/Caching/Redis/RedisMessageCacheManager.cs
+++ b/src/Core/Grand.Infrastructure/Caching/Redis/RedisMessageCacheManager.cs
@@ -1,4 +1,5 @@
using Grand.Infrastructure.Caching.Message;
+using Grand.Infrastructure.Configuration;
using MediatR;
using Microsoft.Extensions.Caching.Memory;
@@ -9,8 +10,8 @@ namespace Grand.Infrastructure.Caching.Redis
private readonly IMemoryCache _cache;
private readonly IMessageBus _messageBus;
- public RedisMessageCacheManager(IMemoryCache cache, IMediator mediator, IMessageBus messageBus)
- : base(cache, mediator)
+ public RedisMessageCacheManager(IMemoryCache cache, IMediator mediator, IMessageBus messageBus, CacheConfig config)
+ : base(cache, mediator, config)
{
_cache = cache;
_messageBus = messageBus;
diff --git a/src/Core/Grand.Infrastructure/Configuration/CacheConfig.cs b/src/Core/Grand.Infrastructure/Configuration/CacheConfig.cs
new file mode 100644
index 000000000..6ab73ee16
--- /dev/null
+++ b/src/Core/Grand.Infrastructure/Configuration/CacheConfig.cs
@@ -0,0 +1,9 @@
+namespace Grand.Infrastructure.Configuration;
+
+public class CacheConfig
+{
+ /// <summary>
+ /// Gets or sets a value indicating for default cache time in minutes
+ /// </summary>
+ public int DefaultCacheTimeMinutes { get; set; }
+}
\ No newline at end of file
diff --git a/src/Core/Grand.Infrastructure/Configuration/PerformanceConfig.cs b/src/Core/Grand.Infrastructure/Configuration/PerformanceConfig.cs
index 145536103..f1f40a838 100644
--- a/src/Core/Grand.Infrastructure/Configuration/PerformanceConfig.cs
+++ b/src/Core/Grand.Infrastructure/Configuration/PerformanceConfig.cs
@@ -15,11 +15,6 @@ namespace Grand.Infrastructure.Configuration
/// </summary>
public bool IgnoreStoreLimitations { get; set; }
- /// <summary>
- /// Gets or sets a value indicating for default cache time in minutes
- /// </summary>
- public int DefaultCacheTimeMinutes { get; set; }
-
/// <summary>
/// Gets or sets a value indicating whether mini profiler should be displayed in public store (used for debugging)
/// </summary>
diff --git a/src/Core/Grand.Infrastructure/StartupBase.cs b/src/Core/Grand.Infrastructure/StartupBase.cs
index 415d46740..ba30857bf 100644
--- a/src/Core/Grand.Infrastructure/StartupBase.cs
+++ b/src/Core/Grand.Infrastructure/StartupBase.cs
@@ -207,6 +207,7 @@ namespace Grand.Infrastructure
var performanceConfig = services.StartupConfig<PerformanceConfig>(configuration.GetSection("Performance"));
var securityConfig = services.StartupConfig<SecurityConfig>(configuration.GetSection("Security"));
services.StartupConfig<ExtensionsConfig>(configuration.GetSection("Extensions"));
+ services.StartupConfig<CacheConfig>(configuration.GetSection("Cache"));
services.StartupConfig<UrlRewriteConfig>(configuration.GetSection("UrlRewrite"));
services.StartupConfig<RedisConfig>(configuration.GetSection("Redis"));
services.StartupConfig<RabbitConfig>(configuration.GetSection("Rabbit"));
@@ -228,7 +229,6 @@ namespace Grand.Infrastructure
CommonPath.WebHostEnvironment = hostingEnvironment.WebRootPath;
CommonPath.BaseDirectory = hostingEnvironment.ContentRootPath;
- CommonHelper.CacheTimeMinutes = performanceConfig.DefaultCacheTimeMinutes;
CommonHelper.CookieAuthExpires =
securityConfig.CookieAuthExpires > 0 ? securityConfig.CookieAuthExpires : 24 * 365;
diff --git a/src/Core/Grand.SharedKernel/Extensions/CommonHelper.cs b/src/Core/Grand.SharedKernel/Extensions/CommonHelper.cs
index ab6dfa736..5b4c21ca8 100644
--- a/src/Core/Grand.SharedKernel/Extensions/CommonHelper.cs
+++ b/src/Core/Grand.SharedKernel/Extensions/CommonHelper.cs
@@ -10,11 +10,6 @@ namespace Grand.SharedKernel.Extensions
/// </summary>
public static class CommonHelper
{
- /// <summary>
- /// Gets or sets application default cache time minutes
- /// </summary>
- public static int CacheTimeMinutes { get; set; }
-
/// <summary>
/// Gets or sets a value indicating for cookie expires in hours
/// </summary>
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Events/Handlers/CategoryDeletedEventHandlerTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Events/Handlers/CategoryDeletedEventHandlerTests.cs
index f8385713d..65b7456e7 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Events/Handlers/CategoryDeletedEventHandlerTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Events/Handlers/CategoryDeletedEventHandlerTests.cs
@@ -4,6 +4,7 @@ using Grand.Domain.Catalog;
using Grand.Domain.Data;
using Grand.Domain.Seo;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -27,7 +28,7 @@ namespace Grand.Business.Catalog.Tests.Events.Handlers
_mediatorMock = new Mock<IMediator>();
_repository = new MongoDBRepositoryTest<Product>();
_entityUrlRepository = new MongoDBRepositoryTest<EntityUrl>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_handler = new CategoryDeletedEventHandler(_entityUrlRepository, _repository, _cacheBase);
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Events/Handlers/CollectionDeletedEventHandlerTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Events/Handlers/CollectionDeletedEventHandlerTests.cs
index 651e4907a..d2633d497 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Events/Handlers/CollectionDeletedEventHandlerTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Events/Handlers/CollectionDeletedEventHandlerTests.cs
@@ -4,6 +4,7 @@ using Grand.Domain.Catalog;
using Grand.Domain.Data;
using Grand.Domain.Seo;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -27,7 +28,7 @@ namespace Grand.Business.Catalog.Tests.Events.Handlers
_mediatorMock = new Mock<IMediator>();
_repository = new MongoDBRepositoryTest<Product>();
_entityUrlRepository = new MongoDBRepositoryTest<EntityUrl>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_handler = new CollectionDeletedEventHandler(_entityUrlRepository, _repository, _cacheBase);
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Events/Handlers/DiscountDeletedEventHandlerTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Events/Handlers/DiscountDeletedEventHandlerTests.cs
index 6ecb7e6c2..8c24aefd5 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Events/Handlers/DiscountDeletedEventHandlerTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Events/Handlers/DiscountDeletedEventHandlerTests.cs
@@ -5,6 +5,7 @@ using Grand.Domain.Data;
using Grand.Domain.Discounts;
using Grand.Domain.Vendors;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -36,7 +37,7 @@ namespace Grand.Business.Catalog.Tests.Events.Handlers
_collectionRepository = new MongoDBRepositoryTest<Collection>();
_vendorRepository = new MongoDBRepositoryTest<Vendor>();
_discountCouponRepository = new MongoDBRepositoryTest<DiscountCoupon>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_handler = new DiscountDeletedEventHandler(_productRepository, _categoryRepository,
_brandRepository, _collectionRepository, _vendorRepository, _discountCouponRepository, _cacheBase);
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandLayoutServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandLayoutServiceTests.cs
index 679ecb25c..34f106c9e 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandLayoutServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandLayoutServiceTests.cs
@@ -3,6 +3,7 @@ using Grand.Data.Tests.MongoDb;
using Grand.Domain.Catalog;
using Grand.Domain.Data;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -24,7 +25,7 @@ namespace Grand.Business.Catalog.Tests.Services.Brands
_repository = new MongoDBRepositoryTest<BrandLayout>();
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_brandLayoutService = new BrandLayoutService(_repository, _cacheBase, _mediatorMock.Object);
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandServiceTests.cs
index fe4b7807a..e0e60b74b 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Brands/BrandServiceTests.cs
@@ -5,6 +5,7 @@ using Grand.Domain.Customers;
using Grand.Domain.Data;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using Grand.SharedKernel.Extensions;
using MediatR;
@@ -32,7 +33,7 @@ namespace Grand.Business.Catalog.Tests.Services.Brands
_workContextMock.Setup(c => c.CurrentStore).Returns(() => new Domain.Stores.Store() { Id = "" });
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_brandService = new BrandService(_cacheBase, _repository, _workContextMock.Object, _mediatorMock.Object);
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryLayoutServiceDbTest.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryLayoutServiceDbTest.cs
index f63a06d02..5f8b587b4 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryLayoutServiceDbTest.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryLayoutServiceDbTest.cs
@@ -3,6 +3,7 @@ using Grand.Data.Tests.MongoDb;
using Grand.Domain.Catalog;
using Grand.Domain.Data;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -24,7 +25,7 @@ namespace Grand.Business.Catalog.Tests.Services.Categories
_repository = new MongoDBRepositoryTest<CategoryLayout>();
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_categoryLayoutService = new CategoryLayoutService(_repository, _cacheBase, _mediatorMock.Object);
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceDbTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceDbTests.cs
index 12bd1ae93..19342591f 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceDbTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/CategoryServiceDbTests.cs
@@ -8,6 +8,7 @@ using Grand.Domain.Data;
using Grand.Domain.Data.Mongo;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Events;
using Grand.Infrastructure.Tests.Caching;
using Grand.SharedKernel.Extensions;
@@ -41,7 +42,7 @@ namespace Grand.Business.Catalog.Tests.Services.Categories
_mediatorMock = new Mock<IMediator>();
_aclServiceMock = new AclService();
_settings = new CatalogSettings();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_categoryService = new CategoryService(_cacheBase, _categoryRepository, _workContextMock.Object, _mediatorMock.Object, _aclServiceMock);
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/ProductCategoryServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/ProductCategoryServiceTests.cs
index 8a78e577e..fe7c546a0 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/ProductCategoryServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Categories/ProductCategoryServiceTests.cs
@@ -5,6 +5,7 @@ using Grand.Domain.Customers;
using Grand.Domain.Data;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using Grand.SharedKernel.Extensions;
using MediatR;
@@ -32,7 +33,7 @@ namespace Grand.Business.Catalog.Tests.Services.Categories
_workContextMock.Setup(c => c.CurrentStore).Returns(() => new Domain.Stores.Store() { Id = "" });
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_productCategoryService = new ProductCategoryService(_repository, _cacheBase, _workContextMock.Object, _mediatorMock.Object);
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/CollectionLayoutServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/CollectionLayoutServiceTests.cs
index 6ded0de53..ab11096fc 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/CollectionLayoutServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/CollectionLayoutServiceTests.cs
@@ -3,6 +3,7 @@ using Grand.Data.Tests.MongoDb;
using Grand.Domain.Catalog;
using Grand.Domain.Data;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -24,7 +25,7 @@ namespace Grand.Business.Catalog.Tests.Services.Collections
_repository = new MongoDBRepositoryTest<CollectionLayout>();
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_collectionLayoutService = new CollectionLayoutService(_repository, _cacheBase, _mediatorMock.Object);
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/ProductCollectionServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/ProductCollectionServiceTests.cs
index f59689148..40647b6d2 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/ProductCollectionServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Collections/ProductCollectionServiceTests.cs
@@ -5,6 +5,7 @@ using Grand.Domain.Customers;
using Grand.Domain.Data;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using Grand.SharedKernel.Extensions;
using MediatR;
@@ -32,7 +33,7 @@ namespace Grand.Business.Catalog.Tests.Services.Collections
_workContextMock.Setup(c => c.CurrentStore).Returns(() => new Domain.Stores.Store() { Id = "" });
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_productCollectionService = new ProductCollectionService(_cacheBase, _repository, _workContextMock.Object, _mediatorMock.Object);
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountServiceTests.cs
index 706c85ce3..35dc7ea46 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Discounts/DiscountServiceTests.cs
@@ -9,6 +9,7 @@ using Grand.Domain.Data;
using Grand.Domain.Discounts;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using Grand.SharedKernel.Extensions;
using MediatR;
@@ -46,7 +47,7 @@ namespace Grand.Business.Catalog.Tests.Services.Discounts
_workContextMock.Setup(c => c.CurrentStore).Returns(() => new Domain.Stores.Store() { Id = "" });
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_discountProviders = new List<IDiscountProvider> { new DiscountProviderTest() };
_discountAmountProviders = new List<IDiscountAmountProvider> { new DiscountAmountProviderTests() };
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/BrandImportDataObjectTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/BrandImportDataObjectTests.cs
index 04afc6c58..be5363c39 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/BrandImportDataObjectTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/BrandImportDataObjectTests.cs
@@ -13,6 +13,7 @@ using Grand.Domain.Data;
using Grand.Domain.Localization;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Mapper;
using Grand.Infrastructure.Tests.Caching;
using Grand.Infrastructure.TypeSearch;
@@ -54,7 +55,7 @@ namespace Grand.Business.Catalog.Tests.Services.ExportImport
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_brandService = new BrandService(_cacheBase, _repository, _workContextMock.Object, _mediatorMock.Object);
_brandImportDataObject = new BrandImportDataObject(_brandService, _pictureServiceMock.Object, _brandLayoutServiceMock.Object, _slugServiceMock.Object, _languageServiceMock.Object, new Domain.Seo.SeoSettings());
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CategoryImportDataObjectTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CategoryImportDataObjectTests.cs
index 90fe25916..595ef965a 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CategoryImportDataObjectTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CategoryImportDataObjectTests.cs
@@ -14,6 +14,7 @@ using Grand.Domain.Data;
using Grand.Domain.Localization;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Mapper;
using Grand.Infrastructure.Tests.Caching;
using Grand.Infrastructure.TypeSearch;
@@ -55,7 +56,7 @@ namespace Grand.Business.Catalog.Tests.Services.ExportImport
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_categoryService = new CategoryService(_cacheBase, _repository, _workContextMock.Object, _mediatorMock.Object, new AclService());
_categoryImportDataObject = new CategoryImportDataObject(_categoryService, _pictureServiceMock.Object, _categoryLayoutServiceMock.Object, _slugServiceMock.Object, _languageServiceMock.Object, new Domain.Seo.SeoSettings());
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CollectionImportDataObjectTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CollectionImportDataObjectTests.cs
index 6034e8716..50a1a0269 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CollectionImportDataObjectTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/CollectionImportDataObjectTests.cs
@@ -14,6 +14,7 @@ using Grand.Domain.Data;
using Grand.Domain.Localization;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Mapper;
using Grand.Infrastructure.Tests.Caching;
using Grand.Infrastructure.TypeSearch;
@@ -55,7 +56,7 @@ namespace Grand.Business.Catalog.Tests.Services.ExportImport
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_collectionService = new CollectionService(_cacheBase, _repository, _workContextMock.Object, _mediatorMock.Object, new AclService());
_collectionImportDataObject = new CollectionImportDataObject(_collectionService, _pictureServiceMock.Object, _collectionLayoutServiceMock.Object, _slugServiceMock.Object, _languageServiceMock.Object, new Domain.Seo.SeoSettings());
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/ProductImportDataObjectTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/ProductImportDataObjectTests.cs
index 7d856e07a..9d49394de 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/ProductImportDataObjectTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/ExportImport/ProductImportDataObjectTests.cs
@@ -20,6 +20,7 @@ using Grand.Domain.Data;
using Grand.Domain.Localization;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Mapper;
using Grand.Infrastructure.Tests.Caching;
using Grand.Infrastructure.TypeSearch;
@@ -80,7 +81,7 @@ namespace Grand.Business.Catalog.Tests.Services.ExportImport
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_productService = new ProductService(_cacheBase, _repository, _workContextMock.Object, _mediatorMock.Object, new AclService());
_productImportDataObject = new ProductImportDataObject
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/AuctionServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/AuctionServiceTests.cs
index ee922fc2f..7649ead07 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/AuctionServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/AuctionServiceTests.cs
@@ -5,6 +5,7 @@ using Grand.Domain.Customers;
using Grand.Domain.Data;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using Grand.SharedKernel.Extensions;
using MediatR;
@@ -34,7 +35,7 @@ namespace Grand.Business.Catalog.Tests.Services.Products
_workContextMock.Setup(c => c.CurrentStore).Returns(() => new Domain.Stores.Store() { Id = "" });
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_auctionService = new AuctionService(_repository, _productrepository, _cacheBase, _mediatorMock.Object);
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/InventoryManageServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/InventoryManageServiceTests.cs
index ceb62476a..2f36f9375 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/InventoryManageServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/InventoryManageServiceTests.cs
@@ -7,6 +7,7 @@ using Grand.Domain.Data;
using Grand.Domain.Shipping;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using Grand.SharedKernel.Extensions;
using MediatR;
@@ -44,7 +45,7 @@ namespace Grand.Business.Catalog.Tests.Services.Products
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
_mediatorMock = new Mock<IMediator>();
_settings = new CatalogSettings();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_stockQuantityService = new StockQuantityService();
_inventoryManageService = new InventoryManageService(_repository, _repositoryInventoryJournal, _stockQuantityService, _cacheBase, _mediatorMock.Object, _settings);
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductAttributeServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductAttributeServiceTests.cs
index 8d1e25af1..64e964bbc 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductAttributeServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductAttributeServiceTests.cs
@@ -3,6 +3,7 @@ using Grand.Data.Tests.MongoDb;
using Grand.Domain.Catalog;
using Grand.Domain.Data;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using Grand.SharedKernel.Extensions;
using MediatR;
@@ -28,7 +29,7 @@ namespace Grand.Business.Catalog.Tests.Services.Products
_repository = new MongoDBRepositoryTest<Product>();
_repositoryproductAttribute = new MongoDBRepositoryTest<ProductAttribute>();
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_productAttributeService = new ProductAttributeService(_cacheBase, _repositoryproductAttribute, _repository, _mediatorMock.Object);
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductLayoutServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductLayoutServiceTests.cs
index 2e37e2ea8..92880552c 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductLayoutServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductLayoutServiceTests.cs
@@ -3,6 +3,7 @@ using Grand.Data.Tests.MongoDb;
using Grand.Domain.Catalog;
using Grand.Domain.Data;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -24,7 +25,7 @@ namespace Grand.Business.Catalog.Tests.Services.Products
_repository = new MongoDBRepositoryTest<ProductLayout>();
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_productLayoutService = new ProductLayoutService(_repository, _cacheBase, _mediatorMock.Object);
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductServiceTests.cs
index 31f40f95c..715827c78 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductServiceTests.cs
@@ -9,6 +9,7 @@ using Grand.Domain.Data;
using Grand.Domain.Orders;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using Grand.SharedKernel.Extensions;
using MediatR;
@@ -42,7 +43,7 @@ namespace Grand.Business.Catalog.Tests.Services.Products
.Returns(Task.FromResult(new Product()));
_aclServiceMock = new AclService();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_productService = new ProductService(_cacheBase, _productRepository, _workContextMock.Object, _mediatorMock.Object, _aclServiceMock);
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductTagServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductTagServiceTests.cs
index 4799872a7..6c8294b8b 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductTagServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/ProductTagServiceTests.cs
@@ -3,6 +3,7 @@ using Grand.Data.Tests.MongoDb;
using Grand.Domain.Catalog;
using Grand.Domain.Data;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using Grand.SharedKernel.Extensions;
using MediatR;
@@ -28,7 +29,7 @@ namespace Grand.Business.Catalog.Tests.Services.Products
_repositoryProductTag = new MongoDBRepositoryTest<ProductTag>();
_productRepository = new MongoDBRepositoryTest<Product>();
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_productTagService = new ProductTagService(_repositoryProductTag, _productRepository, _cacheBase, _mediatorMock.Object);
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/RecentlyViewedProductsServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/RecentlyViewedProductsServiceTests.cs
index 5bccba417..70f5375ab 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/RecentlyViewedProductsServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/RecentlyViewedProductsServiceTests.cs
@@ -4,6 +4,7 @@ using Grand.Data.Tests.MongoDb;
using Grand.Domain.Catalog;
using Grand.Domain.Data;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -27,7 +28,7 @@ namespace Grand.Business.Catalog.Tests.Services.Products
_mediatorMock = new Mock<IMediator>();
_productServiceMock = new Mock<IProductService>();
_productServiceMock.Setup(a => a.GetProductsByIds(It.IsAny<string[]>(), false)).Returns(() => Task.FromResult((IList<Product>)new List<Product>() { new Product() { Id = "1", Published = true }, new Product() { Id = "2", Published = true }, new Product() { Id = "3", Published = true } }));
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_service = new RecentlyViewedProductsService(_productServiceMock.Object, _cacheBase, new CatalogSettings() { RecentlyViewedProductsEnabled = true, RecentlyViewedProductsNumber = 10 }, _repository);
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/SpecificationAttributeServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/SpecificationAttributeServiceTests.cs
index 8c2308716..f63229ecf 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Products/SpecificationAttributeServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Products/SpecificationAttributeServiceTests.cs
@@ -4,6 +4,7 @@ using Grand.Data.Tests.MongoDb;
using Grand.Domain.Catalog;
using Grand.Domain.Data;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -30,7 +31,7 @@ namespace Grand.Business.Catalog.Tests.Services.Products
_mediatorMock = new Mock<IMediator>();
_productServiceMock = new Mock<IProductService>();
_productServiceMock.Setup(a => a.GetProductsByIds(It.IsAny<string[]>(), false)).Returns(() => Task.FromResult((IList<Product>)new List<Product>() { new Product() { Id = "1", Published = true }, new Product() { Id = "2", Published = true }, new Product() { Id = "3", Published = true } }));
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
service = new SpecificationAttributeService(_cacheBase, _repository, _repositoryProduct, _mediatorMock.Object);
}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Services/Tax/TaxCategoryServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Services/Tax/TaxCategoryServiceTests.cs
index a6c8b925b..5e893404a 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Services/Tax/TaxCategoryServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Services/Tax/TaxCategoryServiceTests.cs
@@ -3,6 +3,7 @@ using Grand.Data.Tests.MongoDb;
using Grand.Domain.Data;
using Grand.Domain.Tax;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -24,7 +25,7 @@ namespace Grand.Business.Catalog.Tests.Services.Tax
_repository = new MongoDBRepositoryTest<TaxCategory>();
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_taxCategoryService = new TaxCategoryService(_cacheBase, _repository, _mediatorMock.Object);
}
diff --git a/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/MerchandiseReturnServiceTests.cs b/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/MerchandiseReturnServiceTests.cs
index 2026c15f9..fd8f5faeb 100644
--- a/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/MerchandiseReturnServiceTests.cs
+++ b/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/MerchandiseReturnServiceTests.cs
@@ -5,6 +5,7 @@ using Grand.Domain.Catalog;
using Grand.Domain.Data;
using Grand.Domain.Orders;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -40,7 +41,7 @@ namespace Grand.Business.Checkout.Tests.Services.Orders
_mediatorMock.Setup(x => x.Send(It.IsAny<GetMerchandiseReturnQuery>(), default))
.Returns(Task.FromResult(query));
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_merchandiseReturnService = new MerchandiseReturnService(_repository, _merchandiseReturnActionRepository, _merchandiseReturnReasonRepository, _merchandiseReturnNoteRepository, _cacheBase, _mediatorMock.Object);
}
diff --git a/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/OrderTagServiceTests.cs b/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/OrderTagServiceTests.cs
index 8ce09848a..cf69c7e65 100644
--- a/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/OrderTagServiceTests.cs
+++ b/src/Tests/Grand.Business.Checkout.Tests/Services/Orders/OrderTagServiceTests.cs
@@ -3,6 +3,7 @@ using Grand.Data.Tests.MongoDb;
using Grand.Domain.Data;
using Grand.Domain.Orders;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -27,7 +28,7 @@ namespace Grand.Business.Checkout.Tests.Services.Orders
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_service = new OrderTagService(_orderTagRepository, _orderRepository, _cacheBase, _mediatorMock.Object);
}
diff --git a/src/Tests/Grand.Business.Cms.Tests/Services/KnowledgebaseServiceTests.cs b/src/Tests/Grand.Business.Cms.Tests/Services/KnowledgebaseServiceTests.cs
index 2871c2cf0..5ce8806f8 100644
--- a/src/Tests/Grand.Business.Cms.Tests/Services/KnowledgebaseServiceTests.cs
+++ b/src/Tests/Grand.Business.Cms.Tests/Services/KnowledgebaseServiceTests.cs
@@ -5,6 +5,7 @@ using Grand.Domain.Data;
using Grand.Domain.Knowledgebase;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -38,7 +39,7 @@ namespace Grand.Business.Cms.Tests.Services
_workContextMock.Setup(c => c.CurrentStore).Returns(() => new Domain.Stores.Store() { Id = "", Name = "test store" });
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_knowledgebaseService = new KnowledgebaseService(_repositoryKnowledgebaseCategory, _repositoryKnowledgebaseArticle, _repositoryKnowledgebaseArticleComment, _mediatorMock.Object,
_workContextMock.Object, _cacheBase);
}
diff --git a/src/Tests/Grand.Business.Cms.Tests/Services/PageLayoutServiceTests.cs b/src/Tests/Grand.Business.Cms.Tests/Services/PageLayoutServiceTests.cs
index 8cdb46360..90fff406b 100644
--- a/src/Tests/Grand.Business.Cms.Tests/Services/PageLayoutServiceTests.cs
+++ b/src/Tests/Grand.Business.Cms.Tests/Services/PageLayoutServiceTests.cs
@@ -5,6 +5,7 @@ using Grand.Domain.Data;
using Grand.Domain.Pages;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -30,7 +31,7 @@ namespace Grand.Business.Cms.Tests.Services
_mediatorMock = new Mock<IMediator>();
_workContextMock = new Mock<IWorkContext>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_workContextMock.Setup(c => c.CurrentStore).Returns(() => new Domain.Stores.Store() { Id = "", Name = "test store" });
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
diff --git a/src/Tests/Grand.Business.Cms.Tests/Services/PageServiceTests.cs b/src/Tests/Grand.Business.Cms.Tests/Services/PageServiceTests.cs
index f986a85f9..b507b712f 100644
--- a/src/Tests/Grand.Business.Cms.Tests/Services/PageServiceTests.cs
+++ b/src/Tests/Grand.Business.Cms.Tests/Services/PageServiceTests.cs
@@ -7,6 +7,7 @@ using Grand.Domain.Data;
using Grand.Domain.Pages;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -33,7 +34,7 @@ namespace Grand.Business.Cms.Tests.Services
_mediatorMock = new Mock<IMediator>();
_workContextMock = new Mock<IWorkContext>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_aclService = new AclService();
diff --git a/src/Tests/Grand.Business.Cms.Tests/Services/RobotsTxtServiceTests.cs b/src/Tests/Grand.Business.Cms.Tests/Services/RobotsTxtServiceTests.cs
index 597d43f0f..29362bbe6 100644
--- a/src/Tests/Grand.Business.Cms.Tests/Services/RobotsTxtServiceTests.cs
+++ b/src/Tests/Grand.Business.Cms.Tests/Services/RobotsTxtServiceTests.cs
@@ -5,6 +5,7 @@ using Grand.Domain.Customers;
using Grand.Domain.Data;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -30,7 +31,7 @@ namespace Grand.Business.Cms.Tests.Services
_mediatorMock = new Mock<IMediator>();
_workContextMock = new Mock<IWorkContext>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_workContextMock.Setup(c => c.CurrentStore).Returns(() => new Domain.Stores.Store() { Id = "", Name = "test store" });
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
diff --git a/src/Tests/Grand.Business.Common.Tests/Events/GroupDeletedEventHandlerTests.cs b/src/Tests/Grand.Business.Common.Tests/Events/GroupDeletedEventHandlerTests.cs
index 0495a6dc0..6dd73ce83 100644
--- a/src/Tests/Grand.Business.Common.Tests/Events/GroupDeletedEventHandlerTests.cs
+++ b/src/Tests/Grand.Business.Common.Tests/Events/GroupDeletedEventHandlerTests.cs
@@ -4,6 +4,7 @@ using Grand.Domain.Catalog;
using Grand.Domain.Customers;
using Grand.Domain.Data;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -24,7 +25,7 @@ namespace Grand.Business.Common.Tests.Events
{
_repository = new MongoDBRepositoryTest<Customer>();
_product = new MongoDBRepositoryTest<Product>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), new Mock<IMediator>().Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), new Mock<IMediator>().Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_handler = new GroupDeletedEventHandler(_repository, _product, _cacheBase);
}
diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Directory/CountryServiceTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/Directory/CountryServiceTests.cs
index 773415ebf..c113af82b 100644
--- a/src/Tests/Grand.Business.Common.Tests/Services/Directory/CountryServiceTests.cs
+++ b/src/Tests/Grand.Business.Common.Tests/Services/Directory/CountryServiceTests.cs
@@ -3,6 +3,7 @@ using Grand.Data.Tests.MongoDb;
using Grand.Domain.Data;
using Grand.Domain.Directory;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -24,7 +25,7 @@ namespace Grand.Business.Common.Tests.Services.Directory
_repository = new MongoDBRepositoryTest<Country>();
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_countryService = new CountryService(_repository, _mediatorMock.Object, _cacheBase);
}
diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Directory/CurrencyServiceTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/Directory/CurrencyServiceTests.cs
index 84f2c84a3..372a7aa68 100644
--- a/src/Tests/Grand.Business.Common.Tests/Services/Directory/CurrencyServiceTests.cs
+++ b/src/Tests/Grand.Business.Common.Tests/Services/Directory/CurrencyServiceTests.cs
@@ -33,7 +33,6 @@ namespace Grand.Business.Common.Tests.Services.Directory
public void TestInitialize()
{
CommonPath.BaseDirectory = "";
- CommonHelper.CacheTimeMinutes = 10;
currencyUSD = new Currency {
Id = "1",
diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Directory/GroupServiceTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/Directory/GroupServiceTests.cs
index a94930a96..28ccd0d4a 100644
--- a/src/Tests/Grand.Business.Common.Tests/Services/Directory/GroupServiceTests.cs
+++ b/src/Tests/Grand.Business.Common.Tests/Services/Directory/GroupServiceTests.cs
@@ -3,6 +3,7 @@ using Grand.Data.Tests.MongoDb;
using Grand.Domain.Customers;
using Grand.Domain.Data;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -24,7 +25,7 @@ namespace Grand.Business.Common.Tests.Services.Directory
_repository = new MongoDBRepositoryTest<CustomerGroup>();
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_groupService = new GroupService(_repository, _cacheBase, _mediatorMock.Object);
}
diff --git a/src/Tests/Grand.Business.Common.Tests/Services/ExportImport/CountryImportDataObjectTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/ExportImport/CountryImportDataObjectTests.cs
index e522f16b8..370d2fab7 100644
--- a/src/Tests/Grand.Business.Common.Tests/Services/ExportImport/CountryImportDataObjectTests.cs
+++ b/src/Tests/Grand.Business.Common.Tests/Services/ExportImport/CountryImportDataObjectTests.cs
@@ -6,6 +6,7 @@ using Grand.Data.Tests.MongoDb;
using Grand.Domain.Data;
using Grand.Domain.Directory;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -29,7 +30,7 @@ namespace Grand.Business.Common.Tests.Services.ExportImport
_repository = new MongoDBRepositoryTest<Country>();
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_countryService = new CountryService(_repository, _mediatorMock.Object, _cacheBase);
_countryImportDataObject = new CountryImportDataObject(_countryService);
}
diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Localization/LanguageServiceTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/Localization/LanguageServiceTests.cs
index c21577e8b..a1835c375 100644
--- a/src/Tests/Grand.Business.Common.Tests/Services/Localization/LanguageServiceTests.cs
+++ b/src/Tests/Grand.Business.Common.Tests/Services/Localization/LanguageServiceTests.cs
@@ -3,6 +3,7 @@ using Grand.Data.Tests.MongoDb;
using Grand.Domain.Data;
using Grand.Domain.Localization;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -25,7 +26,7 @@ namespace Grand.Business.Common.Tests.Services.Localization
_repository = new MongoDBRepositoryTest<Language>();
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_languageService = new LanguageService(_cacheBase, _repository, _mediatorMock.Object);
}
diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Localization/TranslationServiceTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/Localization/TranslationServiceTests.cs
index d0240b693..dd0fc62a9 100644
--- a/src/Tests/Grand.Business.Common.Tests/Services/Localization/TranslationServiceTests.cs
+++ b/src/Tests/Grand.Business.Common.Tests/Services/Localization/TranslationServiceTests.cs
@@ -5,6 +5,7 @@ using Grand.Domain.Data;
using Grand.Domain.Localization;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -28,7 +29,7 @@ namespace Grand.Business.Common.Tests.Services.Localization
_repository = new MongoDBRepositoryTest<TranslationResource>();
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_workContextMock = new Mock<IWorkContext>();
_workContextMock.Setup(c => c.CurrentStore).Returns(() => new Domain.Stores.Store());
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Logging/CustomerActivityServiceTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/Logging/CustomerActivityServiceTests.cs
index 9bf784570..236f15873 100644
--- a/src/Tests/Grand.Business.Common.Tests/Services/Logging/CustomerActivityServiceTests.cs
+++ b/src/Tests/Grand.Business.Common.Tests/Services/Logging/CustomerActivityServiceTests.cs
@@ -3,6 +3,7 @@ using Grand.Data.Tests.MongoDb;
using Grand.Domain.Data;
using Grand.Domain.Logging;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -27,7 +28,7 @@ namespace Grand.Business.Common.Tests.Services.Logging
_repositoryActivityLogType = new MongoDBRepositoryTest<ActivityLogType>();
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_customerActivityService = new CustomerActivityService(_cacheBase, _repository, _repositoryActivityLogType);
}
diff --git a/src/Tests/Grand.Business.Common.Tests/Services/Seo/SlugServiceTests.cs b/src/Tests/Grand.Business.Common.Tests/Services/Seo/SlugServiceTests.cs
index 911172541..da4ff200b 100644
--- a/src/Tests/Grand.Business.Common.Tests/Services/Seo/SlugServiceTests.cs
+++ b/src/Tests/Grand.Business.Common.Tests/Services/Seo/SlugServiceTests.cs
@@ -4,6 +4,7 @@ using Grand.Domain.Catalog;
using Grand.Domain.Data;
using Grand.Domain.Seo;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -26,7 +27,7 @@ namespace Grand.Business.Common.Tests.Services.Seo
_repository = new MongoDBRepositoryTest<EntityUrl>();
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_slugService = new SlugService(_cacheBase, _repository);
}
diff --git a/src/Tests/Grand.Business.Customers.Tests/Services/SalesEmployeeServiceTests.cs b/src/Tests/Grand.Business.Customers.Tests/Services/SalesEmployeeServiceTests.cs
index b99d9656c..3e3acfc3f 100644
--- a/src/Tests/Grand.Business.Customers.Tests/Services/SalesEmployeeServiceTests.cs
+++ b/src/Tests/Grand.Business.Customers.Tests/Services/SalesEmployeeServiceTests.cs
@@ -3,6 +3,7 @@ using Grand.Data.Tests.MongoDb;
using Grand.Domain.Customers;
using Grand.Domain.Data;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -24,7 +25,7 @@ namespace Grand.Business.Customers.Tests.Services
_repository = new MongoDBRepositoryTest<SalesEmployee>();
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_salesEmployeeService = new SalesEmployeeService(_repository, _mediatorMock.Object, _cacheBase);
}
diff --git a/src/Tests/Grand.Business.Marketing.Tests/Services/Contacts/ContactAttributeServiceTests.cs b/src/Tests/Grand.Business.Marketing.Tests/Services/Contacts/ContactAttributeServiceTests.cs
index bcc1262a0..3a7ced7fe 100644
--- a/src/Tests/Grand.Business.Marketing.Tests/Services/Contacts/ContactAttributeServiceTests.cs
+++ b/src/Tests/Grand.Business.Marketing.Tests/Services/Contacts/ContactAttributeServiceTests.cs
@@ -5,6 +5,7 @@ using Grand.Domain.Data;
using Grand.Domain.Messages;
using Grand.Infrastructure;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -30,7 +31,7 @@ namespace Grand.Business.Marketing.Tests.Services.Contacts
_workContextMock.Setup(c => c.CurrentStore).Returns(() => new Domain.Stores.Store() { Id = "" });
_workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Customer());
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_contactAttributeService = new ContactAttributeService(_cacheBase, _repository, _mediatorMock.Object, _workContextMock.Object);
}
diff --git a/src/Tests/Grand.Business.Marketing.Tests/Services/Customers/CustomerProductServiceTests.cs b/src/Tests/Grand.Business.Marketing.Tests/Services/Customers/CustomerProductServiceTests.cs
index de8f96d4e..e8591eaaa 100644
--- a/src/Tests/Grand.Business.Marketing.Tests/Services/Customers/CustomerProductServiceTests.cs
+++ b/src/Tests/Grand.Business.Marketing.Tests/Services/Customers/CustomerProductServiceTests.cs
@@ -3,6 +3,7 @@ using Grand.Data.Tests.MongoDb;
using Grand.Domain.Customers;
using Grand.Domain.Data;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -26,7 +27,7 @@ namespace Grand.Business.Marketing.Tests.Services.Customers
_repositoryCustomerProduct = new MongoDBRepositoryTest<CustomerProduct>();
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_customerProductService = new CustomerProductService(_repositoryCustomerProductPrice, _repositoryCustomerProduct, _cacheBase, _mediatorMock.Object);
}
diff --git a/src/Tests/Grand.Business.Marketing.Tests/Services/Customers/CustomerTagServiceTests.cs b/src/Tests/Grand.Business.Marketing.Tests/Services/Customers/CustomerTagServiceTests.cs
index a259bcfb3..eeffc8e0b 100644
--- a/src/Tests/Grand.Business.Marketing.Tests/Services/Customers/CustomerTagServiceTests.cs
+++ b/src/Tests/Grand.Business.Marketing.Tests/Services/Customers/CustomerTagServiceTests.cs
@@ -3,6 +3,7 @@ using Grand.Data.Tests.MongoDb;
using Grand.Domain.Customers;
using Grand.Domain.Data;
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.Infrastructure.Tests.Caching;
using MediatR;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -29,7 +30,7 @@ namespace Grand.Business.Marketing.Tests.Services.Customers
_repositoryCustomer = new MongoDBRepositoryTest<Customer>();
_mediatorMock = new Mock<IMediator>();
- _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object, new CacheConfig(){ DefaultCacheTimeMinutes = 1});
_customerTagService = new CustomerTagService(_repositoryCustomerTag, _repositoryCustomerTagProduct, _repositoryCustomer, _mediatorMock.Object, _cacheBase);
}
diff --git a/src/Tests/Grand.Infrastructure.Tests/Caching/MemoryCacheBaseTests.cs b/src/Tests/Grand.Infrastructure.Tests/Caching/MemoryCacheBaseTests.cs
index 77dfa5936..a46305364 100644
--- a/src/Tests/Grand.Infrastructure.Tests/Caching/MemoryCacheBaseTests.cs
+++ b/src/Tests/Grand.Infrastructure.Tests/Caching/MemoryCacheBaseTests.cs
@@ -1,4 +1,5 @@
using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Configuration;
using Grand.SharedKernel.Extensions;
using MediatR;
using Microsoft.Extensions.Caching.Memory;
@@ -14,25 +15,25 @@ namespace Grand.Infrastructure.Tests.Caching
private Mock<IMediator> _mediatorMock;
private MemoryCacheBase _service;
private IMemoryCache _memoryCache;
-
+ private CacheConfig _config;
+
[TestInitialize]
public void Init()
{
- CommonHelper.CacheTimeMinutes = 1;
-
+ _config = new CacheConfig() { DefaultCacheTimeMinutes = 1 };
var services = new ServiceCollection();
services.AddMemoryCache();
+ services.AddSingleton<CacheConfig>(_config);
var serviceProvider = services.BuildServiceProvider();
_memoryCache = serviceProvider.GetService<IMemoryCache>();
_mediatorMock = new Mock<IMediator>();
- _service = new MemoryCacheBase(_memoryCache, _mediatorMock.Object);
+ _service = new MemoryCacheBase(_memoryCache, _mediatorMock.Object, _config);
}
[TestMethod()]
public async Task GetAsyncTest()
{
- CommonHelper.CacheTimeMinutes = 10;
var result = await _service.GetAsync<string>("key", () => { return Task.FromResult("test"); });
Assert.AreEqual(result, "test");
}
diff --git a/src/Tests/Grand.Infrastructure.Tests/Caching/MemoryCacheTest.cs b/src/Tests/Grand.Infrastructure.Tests/Caching/MemoryCacheTest.cs
index 202234cbd..e600181cb 100644
--- a/src/Tests/Grand.Infrastructure.Tests/Caching/MemoryCacheTest.cs
+++ b/src/Tests/Grand.Infrastructure.Tests/Caching/MemoryCacheTest.cs
@@ -1,5 +1,4 @@
-using Grand.SharedKernel.Extensions;
-using Microsoft.Extensions.Caching.Memory;
+using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.DependencyInjection;
namespace Grand.Infrastructure.Tests.Caching
@@ -8,7 +7,6 @@ namespace Grand.Infrastructure.Tests.Caching
{
public static IMemoryCache Get()
{
- CommonHelper.CacheTimeMinutes = 1;
var services = new ServiceCollection();
services.AddMemoryCache();
var serviceProvider = services.BuildServiceProvider();
diff --git a/src/Web/Grand.Web/App_Data/appsettings.json b/src/Web/Grand.Web/App_Data/appsettings.json
index 754d8d1f9..1939930c4 100644
--- a/src/Web/Grand.Web/App_Data/appsettings.json
+++ b/src/Web/Grand.Web/App_Data/appsettings.json
@@ -91,7 +91,10 @@
//This is the one you should be targeting if your production environment fully runs on HTTPS
"CookieSecurePolicyAlways": false
},
-
+ "Cache": {
+ //Gets or sets a value indicating for default cache time in minutes"
+ "DefaultCacheTimeMinutes": 60
+ },
"Extensions": {
//For developers - more info you can find at https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/
@@ -124,9 +127,6 @@
//You may want to disable it, for example, If you have an active IIS Dynamic Compression Module configured at the server level
"UseResponseCompression": false,
- //Gets or sets a value indicating for default cache time in minutes"
- "DefaultCacheTimeMinutes": 60,
-
/// A value indicating whether to ignore ACL rules
"IgnoreAcl": false,