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.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Catalog tests - remove unused using
KrzysztofPajak6bb7cf396c95
diff --git a/src/Tests/Grand.Business.Catalog.Tests/Extensions/ProductAttributeExtensionsTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Extensions/ProductAttributeExtensionsTests.csindex a4b11a6e3..7d8638f2f 100644--- a/src/Tests/Grand.Business.Catalog.Tests/Extensions/ProductAttributeExtensionsTests.cs+++ b/src/Tests/Grand.Business.Catalog.Tests/Extensions/ProductAttributeExtensionsTests.cs@@ -1,11 +1,6 @@using Grand.Business.Catalog.Extensions;using Grand.Domain.Catalog;using Microsoft.VisualStudio.TestTools.UnitTesting;-using System;-using System.Collections.Generic;-using System.Linq;-using System.Text;-using System.Threading.Tasks;namespace Grand.Business.Catalog.Tests.Extensions{@@ -17,7 +12,7 @@ namespace Grand.Business.Catalog.Tests.Extensionspublic void ShouldHaveValues_ReturnExpentedResult(){var pam = new ProductAttributeMapping() { AttributeControlTypeId = AttributeControlType.TextBox };- var pam2 = new ProductAttributeMapping() { AttributeControlTypeId = AttributeControlType.MultilineTextbox};+ var pam2 = new ProductAttributeMapping() { AttributeControlTypeId = AttributeControlType.MultilineTextbox };var pam3 = new ProductAttributeMapping() { AttributeControlTypeId = AttributeControlType.Datepicker };var pam4 = new ProductAttributeMapping() { AttributeControlTypeId = AttributeControlType.FileUpload };var pam5 = new ProductAttributeMapping() { AttributeControlTypeId = AttributeControlType.DropdownList };@@ -74,7 +69,7 @@ namespace Grand.Business.Catalog.Tests.Extensionsvar pam4 = new ProductAttributeMapping() { AttributeControlTypeId = AttributeControlType.FileUpload };var pam5 = new ProductAttributeMapping() { AttributeControlTypeId = AttributeControlType.DropdownList };ProductAttributeMapping pam6 = null;- var pam7 = new ProductAttributeMapping() {Combination=true};+ var pam7 = new ProductAttributeMapping() { Combination = true };Assert.AreEqual(true, pam.IsNonCombinable());Assert.AreEqual(true, pam2.IsNonCombinable());Assert.AreEqual(true, pam4.IsNonCombinable());diff --git a/src/Tests/Grand.Business.Catalog.Tests/Extensions/TierPriceExtensionsTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Extensions/TierPriceExtensionsTests.csindex e96eb4552..41640d4b4 100644--- a/src/Tests/Grand.Business.Catalog.Tests/Extensions/TierPriceExtensionsTests.cs+++ b/src/Tests/Grand.Business.Catalog.Tests/Extensions/TierPriceExtensionsTests.cs@@ -1,11 +1,8 @@using Grand.Business.Catalog.Extensions;using Grand.Domain.Catalog;using Microsoft.VisualStudio.TestTools.UnitTesting;-using System;using System.Collections.Generic;using System.Linq;-using System.Text;-using System.Threading.Tasks;namespace Grand.Business.Catalog.Tests.Extensions{@@ -18,43 +15,37 @@ namespace Grand.Business.Catalog.Tests.Extensions{var tierPrices = new List<TierPrice>();- tierPrices.Add(new TierPrice- {+ tierPrices.Add(new TierPrice {//will be removedId = "1",Price = 150,Quantity = 1});- tierPrices.Add(new TierPrice- {+ tierPrices.Add(new TierPrice {//will stayId = "2",Price = 100,Quantity = 1});- tierPrices.Add(new TierPrice- {+ tierPrices.Add(new TierPrice {//will stayId = "3",Price = 200,Quantity = 3});- tierPrices.Add(new TierPrice- {+ tierPrices.Add(new TierPrice {//will stayId = "4",Price = 250,Quantity = 4});- tierPrices.Add(new TierPrice- {+ tierPrices.Add(new TierPrice {//will be removedId = "5",Price = 300,Quantity = 4});- tierPrices.Add(new TierPrice- {+ tierPrices.Add(new TierPrice {//will stayId = "6",Price = 350,diff --git a/src/Tests/Grand.Business.Catalog.Tests/Service/Category/CategoryLayoutServiceTest.cs b/src/Tests/Grand.Business.Catalog.Tests/Service/Category/CategoryLayoutServiceTest.csindex 08d8c5f37..639143139 100644--- a/src/Tests/Grand.Business.Catalog.Tests/Service/Category/CategoryLayoutServiceTest.cs+++ b/src/Tests/Grand.Business.Catalog.Tests/Service/Category/CategoryLayoutServiceTest.cs@@ -6,10 +6,6 @@ using Grand.Infrastructure.Events;using MediatR;using Microsoft.VisualStudio.TestTools.UnitTesting;using Moq;-using System;-using System.Collections.Generic;-using System.Linq;-using System.Text;using System.Threading;using System.Threading.Tasks;diff --git a/src/Tests/Grand.Business.Catalog.Tests/Service/Collections/CollectionServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Service/Collections/CollectionServiceTests.csindex 064e94cef..8ed080f83 100644--- a/src/Tests/Grand.Business.Catalog.Tests/Service/Collections/CollectionServiceTests.cs+++ b/src/Tests/Grand.Business.Catalog.Tests/Service/Collections/CollectionServiceTests.cs@@ -10,9 +10,6 @@ using MediatR;using Microsoft.VisualStudio.TestTools.UnitTesting;using Moq;using System;-using System.Collections.Generic;-using System.Linq;-using System.Text;using System.Threading;using System.Threading.Tasks;@@ -38,8 +35,8 @@ namespace Grand.Business.Catalog.Tests.Service.Collections_mediatorMock = new Mock<IMediator>();_aclMock = new Mock<IAclService>();_settings = new CatalogSettings();- _collectionService = new CollectionService(_cacheMock.Object,_repositoryMock.Object,_workContextMock.Object- ,_mediatorMock.Object,_aclMock.Object);+ _collectionService = new CollectionService(_cacheMock.Object, _repositoryMock.Object, _workContextMock.Object+ , _mediatorMock.Object, _aclMock.Object);}@@ -70,12 +67,12 @@ namespace Grand.Business.Catalog.Tests.Service.Collections_cacheMock.Verify(c => c.RemoveByPrefix(It.IsAny<string>(), true));_mediatorMock.Verify(c => c.Publish(It.IsAny<EntityUpdated<Collection>>(), default(CancellationToken)), Times.Once);}-+[TestMethod()]public async Task GeCollectionById_ValidArgument_GetByCache(){await _collectionService.GetCollectionById("id");- _cacheMock.Verify(c => c.GetAsync<Collection>(It.IsAny<string>(), It.IsAny<Func<Task<Collection>>>()),Times.Once);+ _cacheMock.Verify(c => c.GetAsync<Collection>(It.IsAny<string>(), It.IsAny<Func<Task<Collection>>>()), Times.Once);}[TestMethod()]diff --git a/src/Tests/Grand.Business.Catalog.Tests/Service/Prices/PriceFormatterTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Service/Prices/PriceFormatterTests.csindex 7f49147a7..eebf584b6 100644--- a/src/Tests/Grand.Business.Catalog.Tests/Service/Prices/PriceFormatterTests.cs+++ b/src/Tests/Grand.Business.Catalog.Tests/Service/Prices/PriceFormatterTests.cs@@ -16,7 +16,6 @@ using MediatR;using Microsoft.VisualStudio.TestTools.UnitTesting;using Moq;using System;-using System.Linq;using System.Threading;namespace Grand.Business.Catalog.Tests.Service.Pricesdiff --git a/src/Tests/Grand.Business.Catalog.Tests/Service/Prices/PriceServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Service/Prices/PriceServiceTests.csindex e6dbcc769..39cd2f501 100644--- a/src/Tests/Grand.Business.Catalog.Tests/Service/Prices/PriceServiceTests.cs+++ b/src/Tests/Grand.Business.Catalog.Tests/Service/Prices/PriceServiceTests.cs@@ -25,7 +25,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;using Moq;using System;using System.Collections.Generic;-using System.Linq;using System.Threading.Tasks;namespace Grand.Business.Catalog.Tests.Service.Pricesdiff --git a/src/Tests/Grand.Business.Catalog.Tests/Service/Products/CompareProductsServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Service/Products/CompareProductsServiceTests.csindex 59bea30ab..3cc223912 100644--- a/src/Tests/Grand.Business.Catalog.Tests/Service/Products/CompareProductsServiceTests.cs+++ b/src/Tests/Grand.Business.Catalog.Tests/Service/Products/CompareProductsServiceTests.cs@@ -4,10 +4,8 @@ using Grand.Domain.Catalog;using Microsoft.AspNetCore.Http;using Microsoft.VisualStudio.TestTools.UnitTesting;using Moq;-using System;using System.Collections.Generic;using System.Linq;-using System.Text;using System.Threading.Tasks;namespace Grand.Business.Catalog.Tests.Service.Productsdiff --git a/src/Tests/Grand.Business.Catalog.Tests/Service/Products/CopyProductServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Service/Products/CopyProductServiceTests.csindex 5c5d1cc4b..cdf27e9e4 100644--- a/src/Tests/Grand.Business.Catalog.Tests/Service/Products/CopyProductServiceTests.cs+++ b/src/Tests/Grand.Business.Catalog.Tests/Service/Products/CopyProductServiceTests.cs@@ -10,8 +10,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;using Moq;using System;using System.Collections.Generic;-using System.Linq;-using System.Text;using System.Threading.Tasks;namespace Grand.Business.Catalog.Tests.Service.Products@@ -45,17 +43,16 @@ namespace Grand.Business.Catalog.Tests.Service.Productspublic async Task CopyProduct_InserAndReturnNewProduct(){_langServiceMock.Setup(c => c.GetAllLanguages(It.IsAny<bool>(), It.IsAny<string>())).Returns(Task.FromResult<IList<Language>>(new List<Language>()));- var product = new Product()- {+ var product = new Product() {Name = "name",Price = 49,CreatedOnUtc = DateTime.UtcNow,- ShortDescription="Desc"+ ShortDescription = "Desc"};var copy = await _copyProductService.CopyProduct(product, "copy-product");Assert.AreEqual(copy.Price, product.Price);Assert.AreEqual(copy.ShortDescription, product.ShortDescription);-+Assert.AreNotEqual(copy.SeName, product.SeName);Assert.AreNotEqual(copy.Id, product.Id);diff --git a/src/Tests/Grand.Business.Catalog.Tests/Service/Products/CustomerGroupProductServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Service/Products/CustomerGroupProductServiceTests.csindex c762e5aa0..292bfee81 100644--- a/src/Tests/Grand.Business.Catalog.Tests/Service/Products/CustomerGroupProductServiceTests.cs+++ b/src/Tests/Grand.Business.Catalog.Tests/Service/Products/CustomerGroupProductServiceTests.cs@@ -8,8 +8,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;using Moq;using System;using System.Collections.Generic;-using System.Linq;-using System.Text;using System.Threading;using System.Threading.Tasks;@@ -29,7 +27,7 @@ namespace Grand.Business.Catalog.Tests.Service.Products_repositoryMock = new Mock<IRepository<CustomerGroupProduct>>();_mediatorMock = new Mock<IMediator>();_cacheMock = new Mock<ICacheBase>();- _custometGroupService = new CustomerGroupProductService(_repositoryMock.Object,_cacheMock.Object,_mediatorMock.Object);+ _custometGroupService = new CustomerGroupProductService(_repositoryMock.Object, _cacheMock.Object, _mediatorMock.Object);}[TestMethod()]@@ -56,7 +54,7 @@ namespace Grand.Business.Catalog.Tests.Service.Products{await _custometGroupService.GetCustomerGroupProducts("id");//get by cache- _cacheMock.Verify(c => c.GetAsync<List<CustomerGroupProduct>>(It.IsAny<string>(),It.IsAny<Func<Task<List<CustomerGroupProduct>>>>()), Times.Exactly(1));+ _cacheMock.Verify(c => c.GetAsync<List<CustomerGroupProduct>>(It.IsAny<string>(), It.IsAny<Func<Task<List<CustomerGroupProduct>>>>()), Times.Exactly(1));}}}diff --git a/src/Tests/Grand.Business.Catalog.Tests/Service/Products/ProductAttributeParserTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Service/Products/ProductAttributeParserTests.csindex e133bd846..f5384b854 100644--- a/src/Tests/Grand.Business.Catalog.Tests/Service/Products/ProductAttributeParserTests.cs+++ b/src/Tests/Grand.Business.Catalog.Tests/Service/Products/ProductAttributeParserTests.cs@@ -2,11 +2,8 @@using Grand.Domain.Catalog;using Grand.Domain.Common;using Microsoft.VisualStudio.TestTools.UnitTesting;-using System;using System.Collections.Generic;using System.Linq;-using System.Text;-using System.Threading.Tasks;namespace Grand.Business.Catalog.Tests.Service.Products{@@ -33,9 +30,9 @@ namespace Grand.Business.Catalog.Tests.Service.Productspublic void ParseProductAttributeMappings_ReturnExpectedValues(){var product = new Product();- product.ProductAttributeMappings.Add(new ProductAttributeMapping() { Id="key1"});- product.ProductAttributeMappings.Add(new ProductAttributeMapping() { Id="key2"});- var result = _parrser.ParseProductAttributeMappings(product, customAtr);+ product.ProductAttributeMappings.Add(new ProductAttributeMapping() { Id = "key1" });+ product.ProductAttributeMappings.Add(new ProductAttributeMapping() { Id = "key2" });+ var result = _parrser.ParseProductAttributeMappings(product, customAtr);Assert.IsTrue(result.Any(c => c.Id.Equals("key1")));Assert.IsTrue(result.Any(c => c.Id.Equals("key2")));@@ -63,7 +60,7 @@ namespace Grand.Business.Catalog.Tests.Service.Productsvar mapping2 = new ProductAttributeMapping() { Id = "key2" };mapping2.ProductAttributeValues.Add(new ProductAttributeValue() { Id = "value2" });product.ProductAttributeMappings.Add(mapping2);- var result = _parrser.ParseProductAttributeValues(product,customAtr);+ var result = _parrser.ParseProductAttributeValues(product, customAtr);Assert.IsTrue(result.Any(c => c.Id.Equals("value1")));Assert.IsTrue(result.Any(c => c.Id.Equals("value2")));@@ -82,7 +79,7 @@ namespace Grand.Business.Catalog.Tests.Service.Productspublic void AddProductAttribute_ReturnExpectedValues(){var result = _parrser.AddProductAttribute(customAtr, new ProductAttributeMapping() { Id = "key6" }, "value6");- Assert.IsTrue(result.Count==5);+ Assert.IsTrue(result.Count == 5);Assert.IsTrue(result.Last().Value.Equals("value6"));}@@ -91,7 +88,7 @@ namespace Grand.Business.Catalog.Tests.Service.Products{var result = _parrser.RemoveProductAttribute(customAtr, new ProductAttributeMapping() { Id = "key1" });Assert.IsTrue(result.Count == 3);- Assert.IsFalse(result.Any(c=>c.Key.Equals("key1")));+ Assert.IsFalse(result.Any(c => c.Key.Equals("key1")));}}}diff --git a/src/Tests/Grand.Business.Catalog.Tests/Service/Products/StockQuantityServiceTests.cs b/src/Tests/Grand.Business.Catalog.Tests/Service/Products/StockQuantityServiceTests.csindex e6b91b608..446506a08 100644--- a/src/Tests/Grand.Business.Catalog.Tests/Service/Products/StockQuantityServiceTests.cs+++ b/src/Tests/Grand.Business.Catalog.Tests/Service/Products/StockQuantityServiceTests.cs@@ -1,14 +1,9 @@using Grand.Business.Catalog.Interfaces.Products;-using Moq;-using System;-using System.Collections.Generic;-using System.Linq;-using System.Text;-using System.Threading.Tasks;-using Microsoft.VisualStudio.TestTools.UnitTesting;-using Grand.Domain.Catalog;using Grand.Business.Catalog.Services.Products;using Grand.Business.Common.Interfaces.Localization;+using Grand.Domain.Catalog;+using Microsoft.VisualStudio.TestTools.UnitTesting;+using Moq;namespace Grand.Business.Catalog.Tests.Service.Products{@@ -35,8 +30,7 @@ namespace Grand.Business.Catalog.Tests.Service.Productspublic void Can_calculate_total_quantity_when_we_do_not_use_multiple_warehouses(){//if UseMultipleWarehouses is set to false, it will ignore StockQuantity of attached Warhouses- var product = new Product- {+ var product = new Product {ManageInventoryMethodId = ManageInventoryMethod.ManageStock,UseMultipleWarehouses = false,StockQuantity = 8765@@ -52,8 +46,7 @@ namespace Grand.Business.Catalog.Tests.Service.Products[TestMethod()]public void Can_calculate_total_quantity_when_we_do_use_multiple_warehouses_with_reserved(){- var product = new Product- {+ var product = new Product {ManageInventoryMethodId = ManageInventoryMethod.ManageStock,UseMultipleWarehouses = true, //UseMultipleWarehouse is set to true, so it will show only values of WarehousesStockQuantity = 333334765 //and totally ignores this@@ -78,8 +71,7 @@ namespace Grand.Business.Catalog.Tests.Service.Productspublic void Can_calculate_total_quantity_when_we_do_use_multiple_warehouses_without_reserved(){//if UseMultipleWarehouses is set to true, it will show StockQuantity of attached Warhouses- var product = new Product- {+ var product = new Product {ManageInventoryMethodId = ManageInventoryMethod.ManageStock,UseMultipleWarehouses = true, //so ignore this Product's StockQuantityStockQuantity = 8765@@ -100,8 +92,7 @@ namespace Grand.Business.Catalog.Tests.Service.Productspublic void Can_calculate_total_quantity_when_we_do_use_multiple_warehouses_with_warehouse_specified(){//show only specified Warehouse (by WarehouseID)- var product = new Product- {+ var product = new Product {ManageInventoryMethodId = ManageInventoryMethod.ManageStock,UseMultipleWarehouses = true,StockQuantity = 8765diff --git a/src/Tests/Grand.Business.Catalog.Tests/Service/Tax/FixedRateTestTaxProvider.cs b/src/Tests/Grand.Business.Catalog.Tests/Service/Tax/FixedRateTestTaxProvider.csindex 9f7386378..3ec4807ef 100644--- a/src/Tests/Grand.Business.Catalog.Tests/Service/Tax/FixedRateTestTaxProvider.cs+++ b/src/Tests/Grand.Business.Catalog.Tests/Service/Tax/FixedRateTestTaxProvider.cs@@ -2,10 +2,7 @@using Grand.Business.Catalog.Utilities;using Grand.Infrastructure.Plugins;using Microsoft.AspNetCore.Routing;-using System;using System.Collections.Generic;-using System.Linq;-using System.Text;using System.Threading.Tasks;namespace Grand.Business.Catalog.Tests.Service.Tax@@ -24,7 +21,7 @@ namespace Grand.Business.Catalog.Tests.Service.Taxpublic IList<string> LimitedToGroups => new List<string>();-+/// <summary>/// Gets a tax rate/// </summary>@@ -54,8 +51,7 @@ namespace Grand.Business.Catalog.Tests.Service.Taxpublic Task<TaxResult> GetTaxRate(TaxRequest calculateTaxRequest){- var result = new TaxResult- {+ var result = new TaxResult {TaxRate = GetTaxRate(calculateTaxRequest.TaxCategoryId)};return Task.FromResult(result);