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.

Add tests

supporte396c01d6982
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Grand.Business.Catalog.Tests.csproj b/src/Tests/Grand.Business.Catalog.Tests/Grand.Business.Catalog.Tests.csproj
index a77457ba2..ab2498f6f 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Grand.Business.Catalog.Tests.csproj
+++ b/src/Tests/Grand.Business.Catalog.Tests/Grand.Business.Catalog.Tests.csproj
@@ -19,6 +19,8 @@
<ProjectReference Include="..\..\Business\Grand.Business.Catalog\Grand.Business.Catalog.csproj" />
<ProjectReference Include="..\..\Business\Grand.Business.Common\Grand.Business.Common.csproj" />
<ProjectReference Include="..\..\Business\Grand.Business.Core\Grand.Business.Core.csproj" />
+ <ProjectReference Include="..\Grand.Data.Tests\Grand.Data.Tests.csproj" />
+ <ProjectReference Include="..\Grand.Infrastructure.Tests\Grand.Infrastructure.Tests.csproj" />
</ItemGroup>
</Project>
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Service/Category/CategoryLayoutServiceDbTest.cs b/src/Tests/Grand.Business.Catalog.Tests/Service/Category/CategoryLayoutServiceDbTest.cs
new file mode 100644
index 000000000..340ecb201
--- /dev/null
+++ b/src/Tests/Grand.Business.Catalog.Tests/Service/Category/CategoryLayoutServiceDbTest.cs
@@ -0,0 +1,128 @@
+using Grand.Business.Catalog.Services.Categories;
+using Grand.Data.Tests.MongoDb;
+using Grand.Domain.Catalog;
+using Grand.Domain.Data;
+using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Tests.Caching;
+using MediatR;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+
+namespace Grand.Business.Catalog.Tests.Service.Category
+{
+ [TestClass()]
+ public class CategoryLayoutServiceDbTest
+ {
+ private IRepository<CategoryLayout> _repostiory;
+ private MemoryCacheBase _cacheBase;
+ private Mock<IMediator> _mediatorMock;
+ private CategoryLayoutService _categoryLayoutService;
+
+ [TestInitialize()]
+ public void Init()
+ {
+ _repostiory = new MongoDBRepositoryTest<CategoryLayout>();
+ _mediatorMock = new Mock<IMediator>();
+
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _categoryLayoutService = new CategoryLayoutService(_repostiory, _cacheBase, _mediatorMock.Object);
+ }
+
+ [TestMethod()]
+ public async Task GetCategoryLayoutById()
+ {
+ //Arrange
+ var categoryLayout1 = new CategoryLayout() {
+ Name = "test1"
+ };
+ await _categoryLayoutService.InsertCategoryLayout(categoryLayout1);
+
+ //Assert
+ var layout = await _categoryLayoutService.GetCategoryLayoutById(categoryLayout1.Id);
+
+ //Act
+ Assert.IsNotNull(layout);
+ Assert.AreEqual("test1", layout.Name);
+ }
+ [TestMethod()]
+ public async Task GetAllCategoryLayouts()
+ {
+ //Arrange
+ await _categoryLayoutService.InsertCategoryLayout(new CategoryLayout());
+ await _categoryLayoutService.InsertCategoryLayout(new CategoryLayout());
+ await _categoryLayoutService.InsertCategoryLayout(new CategoryLayout());
+
+ //Assert
+ var layouts = await _categoryLayoutService.GetAllCategoryLayouts();
+
+ //Act
+ Assert.AreEqual(3, layouts.Count);
+ }
+
+ [TestMethod()]
+ public async Task DeleteCategoryLayout()
+ {
+ //Arrange
+ var categoryLayout1 = new CategoryLayout() {
+ Name = "test1"
+ };
+ await _categoryLayoutService.InsertCategoryLayout(categoryLayout1);
+ var categoryLayout2 = new CategoryLayout() {
+ Name = "test2"
+ };
+ await _categoryLayoutService.InsertCategoryLayout(categoryLayout2);
+
+ //Assert
+ await _categoryLayoutService.DeleteCategoryLayout(categoryLayout1);
+
+ //Act
+ Assert.IsNull(_repostiory.Table.FirstOrDefault(x => x.Name == "test1"));
+ Assert.AreEqual(1, _repostiory.Table.Count());
+
+ }
+
+
+ [TestMethod()]
+ public async Task InsertCategoryLayout_True()
+ {
+ //Assert
+ await _categoryLayoutService.InsertCategoryLayout(new CategoryLayout());
+ //Act
+ Assert.IsTrue(_repostiory.Table.Any());
+ }
+
+ [TestMethod()]
+ public async Task UpdateCategoryLayout_IsNotNull()
+ {
+ //Arrange
+ var categoryLayout = new CategoryLayout() {
+ Name = "test"
+ };
+ await _categoryLayoutService.InsertCategoryLayout(categoryLayout);
+ categoryLayout.Name = "test2";
+
+ //Assert
+ await _categoryLayoutService.UpdateCategoryLayout(categoryLayout);
+
+ //Act
+ Assert.IsNotNull(_repostiory.Table.FirstOrDefault(x => x.Name == "test2"));
+ }
+
+ [TestMethod()]
+ public async Task UpdateCategoryLayout_IsNull()
+ {
+ //Arrange
+ var categoryLayout = new CategoryLayout() {
+ Name = "test"
+ };
+ await _categoryLayoutService.InsertCategoryLayout(categoryLayout);
+ categoryLayout.Name = "test2";
+
+ //Assert
+ await _categoryLayoutService.UpdateCategoryLayout(categoryLayout);
+
+ //Act
+ Assert.IsNull(_repostiory.Table.FirstOrDefault(x => x.Name == "test3"));
+ }
+ }
+}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Service/Category/CategoryLayoutServiceTest.cs b/src/Tests/Grand.Business.Catalog.Tests/Service/Category/CategoryLayoutServiceTest.cs
index f6ae4d89c..2996fdf6e 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Service/Category/CategoryLayoutServiceTest.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Service/Category/CategoryLayoutServiceTest.cs
@@ -26,9 +26,20 @@ namespace Grand.Business.Catalog.Tests.Service.Category
_categoryLayoutService = new CategoryLayoutService(_repostioryMock.Object, _cacheMock.Object, _mediatorMock.Object);
}
-
[TestMethod()]
- public async Task DeleteCategoryLayout_ValidArguments_InoveMethods()
+ public async Task GetCategoryLayoutById_InvokeMethods()
+ {
+ await _categoryLayoutService.GetCategoryLayoutById("1");
+ _cacheMock.Verify(c => c.GetAsync<CategoryLayout>(It.IsAny<string>(), It.IsAny<Func<Task<CategoryLayout>>>()), Times.Once);
+ }
+ [TestMethod()]
+ public async Task GetAllCategoryLayouts_InvokeMethods()
+ {
+ await _categoryLayoutService.GetAllCategoryLayouts();
+ _cacheMock.Verify(c => c.GetAsync<List<CategoryLayout>>(It.IsAny<string>(), It.IsAny<Func<Task<List<CategoryLayout>>>>()), Times.Once);
+ }
+ [TestMethod()]
+ public async Task DeleteCategoryLayout_ValidArguments_InvokeMethods()
{
await _categoryLayoutService.DeleteCategoryLayout(new CategoryLayout());
_repostioryMock.Verify(c => c.DeleteAsync(It.IsAny<CategoryLayout>()), Times.Once);
@@ -38,7 +49,7 @@ namespace Grand.Business.Catalog.Tests.Service.Category
[TestMethod()]
- public async Task InsertCategoryLayout_ValidArguments_InoveMethods()
+ public async Task InsertCategoryLayout_ValidArguments_InvokeMethods()
{
await _categoryLayoutService.InsertCategoryLayout(new CategoryLayout());
_repostioryMock.Verify(c => c.InsertAsync(It.IsAny<CategoryLayout>()), Times.Once);
@@ -47,7 +58,7 @@ namespace Grand.Business.Catalog.Tests.Service.Category
}
[TestMethod()]
- public async Task UpdateCategoryLayout_ValidArguments_InoveMethods()
+ public async Task UpdateCategoryLayout_ValidArguments_InvokeMethods()
{
await _categoryLayoutService.UpdateCategoryLayout(new CategoryLayout());
_repostioryMock.Verify(c => c.UpdateAsync(It.IsAny<CategoryLayout>()), Times.Once);
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Service/Category/CategoryServiceDbTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Service/Category/CategoryServiceDbTests.cs
new file mode 100644
index 000000000..83d854cb0
--- /dev/null
+++ b/src/Tests/Grand.Business.Catalog.Tests/Service/Category/CategoryServiceDbTests.cs
@@ -0,0 +1,240 @@
+using Grand.Business.Catalog.Services.Categories;
+using Grand.Business.Common.Services.Security;
+using Grand.Business.Core.Interfaces.Common.Security;
+using Grand.Data.Tests.MongoDb;
+using Grand.Domain.Catalog;
+using Grand.Domain.Customers;
+using Grand.Domain.Data;
+using Grand.Domain.Data.Mongo;
+using Grand.Infrastructure;
+using Grand.Infrastructure.Caching;
+using Grand.Infrastructure.Events;
+using Grand.Infrastructure.Tests.Caching;
+using Grand.SharedKernel.Extensions;
+using MediatR;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
+
+
+namespace Grand.Business.Catalog.Tests.Service.Category
+{
+ [TestClass()]
+ public class CategoryServiceDbTests
+ {
+ private IRepository<Domain.Catalog.Category> _categoryRepository;
+ private Mock<IWorkContext> _workContextMock;
+ private Mock<IMediator> _mediatorMock;
+ private IAclService _aclServiceMock;
+ private CatalogSettings _settings;
+ private CategoryService _categoryService;
+ private MemoryCacheBase _cacheBase;
+
+ [TestInitialize()]
+ public void InitializeTests()
+ {
+ CommonPath.BaseDirectory = "";
+
+ _categoryRepository = new MongoDBRepositoryTest<Grand.Domain.Catalog.Category>();
+ _workContextMock = new Mock<IWorkContext>();
+ _workContextMock.Setup(c => c.CurrentStore).Returns(() => new Domain.Stores.Store() { Id = "" });
+ _workContextMock.Setup(c => c.CurrentCustomer).Returns(() => new Domain.Customers.Customer());
+ _mediatorMock = new Mock<IMediator>();
+ _aclServiceMock = new AclService();
+ _settings = new CatalogSettings();
+ _cacheBase = new MemoryCacheBase(MemoryCacheTest.Get(), _mediatorMock.Object);
+ _categoryService = new CategoryService(_cacheBase, _categoryRepository, _workContextMock.Object, _mediatorMock.Object, _aclServiceMock);
+ }
+
+ [TestMethod()]
+ public async Task InsertCategory()
+ {
+ //Act
+ await _categoryService.InsertCategory(new Domain.Catalog.Category());
+ //Assert
+ Assert.IsTrue(_categoryRepository.Table.Any());
+ }
+
+ [TestMethod()]
+ public async Task UpdateCategory()
+ {
+ //Arrange
+ var category = new Domain.Catalog.Category() { Name = "test" };
+ await _categoryService.InsertCategory(category);
+ category.Name = "test2";
+ //Act
+ await _categoryService.UpdateCategory(category);
+ //Assert
+ Assert.IsNotNull(_categoryRepository.Table.FirstOrDefault(x => x.Name == "test2"));
+ }
+
+ [TestMethod()]
+ public async Task DeleteCategory()
+ {
+ //Arrange
+ var allCategory = GetMockCategoryList();
+ allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult());
+ //Act
+ await _categoryService.DeleteCategory(allCategory.FirstOrDefault(x=>x.Id == "1"));
+ //Assert
+ Assert.IsTrue(_categoryRepository.Table.Count() == 4);
+ Assert.IsNull(_categoryRepository.Table.FirstOrDefault(x=>x.Id == "1"));
+ }
+
+ [TestMethod()]
+ public async Task GetCategoryBreadCrumb()
+ {
+ var allCategory = GetMockCategoryList();
+ allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult());
+ var category = new Grand.Domain.Catalog.Category() { Id = "6", ParentCategoryId = "3", Published = true };
+ await _categoryService.InsertCategory(category);
+ var result = await _categoryService.GetCategoryBreadCrumb(category, false);
+ Assert.IsTrue(result.Count == 2);
+ Assert.IsTrue(result.Any(c => c.Id.Equals("6")));
+ Assert.IsTrue(result.Any(c => c.Id.Equals("3")));
+ }
+
+ [TestMethod()]
+ public void GetCategoryBreadCrumb_AllCategory()
+ {
+ var allCategory = GetMockCategoryList();
+ allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult());
+ var category = new Grand.Domain.Catalog.Category() { ParentCategoryId = "3" };
+ var result = _categoryService.GetCategoryBreadCrumb(category, allCategory);
+ Assert.IsTrue(result.Count == 0);
+ }
+
+ [TestMethod()]
+ public async Task GetAllCategories()
+ {
+ var allCategory = GetMockCategoryList();
+ allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult());
+ var result = await _categoryService.GetAllCategories();
+ Assert.IsTrue(result.Count == 5);
+ }
+ [TestMethod()]
+ public async Task GetMenuCategories()
+ {
+ var allCategory = GetMockCategoryList();
+ allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult());
+ var result = await _categoryService.GetMenuCategories();
+ Assert.IsTrue(result.Count == 1);
+ }
+
+ [TestMethod()]
+ public async Task GetAllCategoriesByParentCategoryId()
+ {
+ var allCategory = GetMockCategoryList();
+ allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult());
+ var result = await _categoryService.GetAllCategoriesByParentCategoryId("5");
+ Assert.IsTrue(result.Count == 1);
+ }
+ [TestMethod()]
+ public async Task GetAllCategoriesDisplayedOnHomePage()
+ {
+ var allCategory = GetMockCategoryList();
+ allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult());
+ var result = await _categoryService.GetAllCategoriesDisplayedOnHomePage();
+ Assert.IsTrue(result.Count == 2);
+ }
+ [TestMethod()]
+ public async Task GetAllCategoriesFeaturedProductsOnHomePage()
+ {
+ var allCategory = GetMockCategoryList();
+ allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult());
+ var result = await _categoryService.GetAllCategoriesFeaturedProductsOnHomePage();
+ Assert.IsTrue(result.Count == 2);
+ }
+ [TestMethod()]
+ public async Task GetAllCategoriesSearchBox()
+ {
+ var allCategory = GetMockCategoryList();
+ allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult());
+ var result = await _categoryService.GetAllCategoriesSearchBox();
+ Assert.IsTrue(result.Count == 2);
+ }
+ [TestMethod()]
+ public async Task GetCategoryById_IsNotNull()
+ {
+ var allCategory = GetMockCategoryList();
+ allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult());
+ var result = await _categoryService.GetCategoryById("1");
+ Assert.IsNotNull(result);
+ }
+ [TestMethod()]
+ public async Task GetCategoryById_IsNull()
+ {
+ var allCategory = GetMockCategoryList();
+ allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult());
+ var result = await _categoryService.GetCategoryById("10");
+ Assert.IsNull(result);
+ }
+ [TestMethod()]
+ public async Task GetCategoryBreadCrumb_ShouldReturnTwoElement()
+ {
+ var allCategory = GetMockCategoryList();
+ allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult());
+ var category = new Grand.Domain.Catalog.Category() { Id = "6", ParentCategoryId = "3", Published = true };
+ await _categoryService.InsertCategory(category);
+ var result = _categoryService.GetCategoryBreadCrumb(category, allCategory);
+ Assert.IsTrue(result.Count == 2);
+ Assert.IsTrue(result.Any(c => c.Id.Equals("6")));
+ Assert.IsTrue(result.Any(c => c.Id.Equals("3")));
+ }
+
+ [TestMethod()]
+ public void GetCategoryBreadCrumb_ShouldReturnThreeElement()
+ {
+ var allCategory = GetMockCategoryList();
+ allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult());
+ var category = new Grand.Domain.Catalog.Category() { Id = "6", ParentCategoryId = "1", Published = true };
+ var result = _categoryService.GetCategoryBreadCrumb(category, allCategory);
+ Assert.IsTrue(result.Count == 3);
+ Assert.IsTrue(result.Any(c => c.Id.Equals("6")));
+ Assert.IsTrue(result.Any(c => c.Id.Equals("1")));
+ Assert.IsTrue(result.Any(c => c.Id.Equals("5")));
+ }
+ [TestMethod()]
+ public async Task GetFormattedBreadCrumb()
+ {
+ var exprectedString = "cat5 >> cat1 >> cat6";
+ var allCategory = GetMockCategoryList();
+ allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult());
+ var category = new Grand.Domain.Catalog.Category() { Id = "6", Name = "cat6", ParentCategoryId = "1", Published = true };
+ var result = await _categoryService.GetFormattedBreadCrumb(category);
+ Assert.IsTrue(exprectedString.Equals(result));
+ }
+ [TestMethod()]
+ public void GetFormattedBreadCrumb_ReturnExprectedString()
+ {
+ var exprectedString = "cat5 >> cat1 >> cat6";
+ var allCategory = GetMockCategoryList();
+ allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult());
+ var category = new Grand.Domain.Catalog.Category() { Id = "6", Name = "cat6", ParentCategoryId = "1", Published = true };
+ var result = _categoryService.GetFormattedBreadCrumb(category, allCategory);
+ Assert.IsTrue(exprectedString.Equals(result));
+ }
+
+ [TestMethod()]
+ public void GetFormattedBreadCrumb_ReturnEmptyString()
+ {
+ var allCategory = GetMockCategoryList();
+ allCategory.ToList().ForEach(x => _categoryService.InsertCategory(x).GetAwaiter().GetResult());
+ var result = _categoryService.GetFormattedBreadCrumb(null, allCategory);
+ Assert.IsTrue(string.IsNullOrEmpty(result));
+ }
+
+
+ private IList<Grand.Domain.Catalog.Category> GetMockCategoryList()
+ {
+ return new List<Grand.Domain.Catalog.Category>()
+ {
+ new Grand.Domain.Catalog.Category(){ Id="1" ,Name="cat1",Published=true,ParentCategoryId="5",FeaturedProductsOnHomePage=true},
+ new Grand.Domain.Catalog.Category(){ Id="2" ,Name="cat2",Published=true,IncludeInMenu = true},
+ new Grand.Domain.Catalog.Category(){ Id="3" ,Name="cat3",Published=true,ShowOnHomePage=true,ShowOnSearchBox=true},
+ new Grand.Domain.Catalog.Category(){ Id="4" ,Name="cat4",Published=true,ShowOnHomePage=true,ShowOnSearchBox=true},
+ new Grand.Domain.Catalog.Category(){ Id="5" ,Name="cat5",Published=true,FeaturedProductsOnHomePage=true},
+ };
+ }
+
+ }
+}
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Service/Collections/CollectionServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Service/Collections/CollectionServiceTests.cs
index 709f02d44..d9a5a2798 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Service/Collections/CollectionServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Service/Collections/CollectionServiceTests.cs
@@ -38,7 +38,7 @@ namespace Grand.Business.Catalog.Tests.Service.Collections
[TestMethod()]
- public async Task DeleteCollection_ValidArguments_InoveMethods()
+ public async Task DeleteCollection_ValidArguments_InvokeMethods()
{
await _collectionService.DeleteCollection(new Collection());
_repositoryMock.Verify(c => c.DeleteAsync(It.IsAny<Collection>()), Times.Once);
@@ -48,7 +48,7 @@ namespace Grand.Business.Catalog.Tests.Service.Collections
[TestMethod()]
- public async Task InsertCollection_ValidArguments_InoveMethods()
+ public async Task InsertCollection_ValidArguments_InvokeMethods()
{
await _collectionService.InsertCollection(new Collection());
_repositoryMock.Verify(c => c.InsertAsync(It.IsAny<Collection>()), Times.Once);
@@ -57,7 +57,7 @@ namespace Grand.Business.Catalog.Tests.Service.Collections
}
[TestMethod()]
- public async Task UpdateCollection_ValidArguments_InoveMethods()
+ public async Task UpdateCollection_ValidArguments_InvokeMethods()
{
await _collectionService.UpdateCollection(new Collection());
_repositoryMock.Verify(c => c.UpdateAsync(It.IsAny<Collection>()), Times.Once);
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Service/Products/CustomerGroupProductServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Service/Products/CustomerGroupProductServiceTests.cs
index 6690fbd97..3bef13ce8 100644
--- a/src/Tests/Grand.Business.Catalog.Tests/Service/Products/CustomerGroupProductServiceTests.cs
+++ b/src/Tests/Grand.Business.Catalog.Tests/Service/Products/CustomerGroupProductServiceTests.cs
@@ -27,7 +27,7 @@ namespace Grand.Business.Catalog.Tests.Service.Products
}
[TestMethod()]
- public async Task DeleteCustomerGroupProduct_ValidArguments_InoveMethods()
+ public async Task DeleteCustomerGroupProduct_ValidArguments_InvokeMethods()
{
await _custometGroupService.DeleteCustomerGroupProduct(new CustomerGroupProduct());
_repositoryMock.Verify(c => c.DeleteAsync(It.IsAny<CustomerGroupProduct>()), Times.Once);
@@ -37,7 +37,7 @@ namespace Grand.Business.Catalog.Tests.Service.Products
[TestMethod()]
- public async Task InsertCustomerGroupProduct_ValidArguments_InoveMethods()
+ public async Task InsertCustomerGroupProduct_ValidArguments_InvokeMethods()
{
await _custometGroupService.InsertCustomerGroupProduct(new CustomerGroupProduct());
_repositoryMock.Verify(c => c.InsertAsync(It.IsAny<CustomerGroupProduct>()), Times.Once);
@@ -46,7 +46,7 @@ namespace Grand.Business.Catalog.Tests.Service.Products
}
[TestMethod()]
- public async Task GetCustomerGroupProducts_ValidArguments_InoveMethods()
+ public async Task GetCustomerGroupProducts_ValidArguments_InvokeMethods()
{
await _custometGroupService.GetCustomerGroupProducts("id");
//get by cache
diff --git a/src/Tests/Grand.Infrastructure.Tests/Caching/MemoryCacheTest.cs b/src/Tests/Grand.Infrastructure.Tests/Caching/MemoryCacheTest.cs
new file mode 100644
index 000000000..ff838111c
--- /dev/null
+++ b/src/Tests/Grand.Infrastructure.Tests/Caching/MemoryCacheTest.cs
@@ -0,0 +1,24 @@
+using Grand.SharedKernel.Extensions;
+using Microsoft.Extensions.Caching.Memory;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace Grand.Infrastructure.Tests.Caching
+{
+ public static class MemoryCacheTest
+ {
+ private static IMemoryCache _memoryCache;
+ public static IMemoryCache Get()
+ {
+ CommonHelper.CacheTimeMinutes = 1;
+ if (_memoryCache == null)
+ {
+ var services = new ServiceCollection();
+ services.AddMemoryCache();
+ var serviceProvider = services.BuildServiceProvider();
+
+ _memoryCache = serviceProvider.GetService<IMemoryCache>();
+ }
+ return _memoryCache;
+ }
+ }
+}