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
Add tests
support644fe72b6650
diff --git a/src/Tests/Grand.Infrastructure.Tests/DiscountProviderTest.cs b/src/Tests/Grand.Infrastructure.Tests/DiscountProviderTest.csnew file mode 100644index 000000000..39a4b594c--- /dev/null+++ b/src/Tests/Grand.Infrastructure.Tests/DiscountProviderTest.cs@@ -0,0 +1,32 @@+using Grand.Business.Core.Interfaces.Catalog.Discounts;++namespace Grand.Infrastructure.Tests+{+ public class DiscountProviderTest : IDiscountProvider+ {+ private IList<string> limitedToStores;+ private IList<string> limitedToGroups;+ public DiscountProviderTest(List<string> stores, IList<string> groups)+ {+ limitedToStores = stores;+ limitedToGroups = groups;+ }++ public string ConfigurationUrl => throw new NotImplementedException();++ public string SystemName => throw new NotImplementedException();++ public string FriendlyName => throw new NotImplementedException();++ public int Priority => throw new NotImplementedException();++ public IList<string> LimitedToStores => limitedToStores;++ public IList<string> LimitedToGroups => limitedToGroups;++ public IList<IDiscountRule> GetRequirementRules()+ {+ throw new NotImplementedException();+ }+ }+}diff --git a/src/Tests/Grand.Infrastructure.Tests/Extensions/ProviderExtensionsTests.cs b/src/Tests/Grand.Infrastructure.Tests/Extensions/ProviderExtensionsTests.csnew file mode 100644index 000000000..a8a1cf3be--- /dev/null+++ b/src/Tests/Grand.Infrastructure.Tests/Extensions/ProviderExtensionsTests.cs@@ -0,0 +1,66 @@+using Grand.Infrastructure.Tests;+using Microsoft.VisualStudio.TestTools.UnitTesting;++namespace Grand.Infrastructure.Extensions.Tests+{+ [TestClass()]+ public class ProviderExtensionsTests+ {++ [TestMethod()]+ public void IsAuthenticateStoreTest_True()+ {+ var discountProvider = new DiscountProviderTest(new List<string>() { "store1", "store2" }, new List<string> { "group1" });+ Assert.IsTrue(discountProvider.IsAuthenticateStore(new Domain.Stores.Store() { Id = "store1" }));+ }+ [TestMethod()]+ public void IsAuthenticateStoreTest_True_NoStores()+ {+ var discountProvider = new DiscountProviderTest(new List<string>() { }, new List<string> { "group1" });+ Assert.IsTrue(discountProvider.IsAuthenticateStore(new Domain.Stores.Store() { Id = "store1" }));+ }+ [TestMethod()]+ public void IsAuthenticateStoreTest_False()+ {+ var discountProvider = new DiscountProviderTest(new List<string>() { "store2" }, new List<string> { "group1" });+ Assert.IsFalse(discountProvider.IsAuthenticateStore(new Domain.Stores.Store() { Id = "store1" }));+ }++ [TestMethod()]+ public void IsAuthenticateStoreTestId_True()+ {+ var discountProvider = new DiscountProviderTest(new List<string>() { "store1", "store2" }, new List<string> { "group1" });+ Assert.IsTrue(discountProvider.IsAuthenticateStore("store1"));+ }+ [TestMethod()]+ public void IsAuthenticateStoreTestId_True_NoStores()+ {+ var discountProvider = new DiscountProviderTest(new List<string>() { }, new List<string> { "group1" });+ Assert.IsTrue(discountProvider.IsAuthenticateStore("store1"));+ }+ [TestMethod()]+ public void IsAuthenticateStoreTestId_False()+ {+ var discountProvider = new DiscountProviderTest(new List<string>() { "store2" }, new List<string> { "group1" });+ Assert.IsFalse(discountProvider.IsAuthenticateStore("store1"));+ }++ [TestMethod()]+ public void IsAuthenticateGroupTest_True()+ {+ var discountProvider = new DiscountProviderTest(new List<string>() { "store2" }, new List<string> { "group1" });+ var customer = new Domain.Customers.Customer();+ customer.Groups.Add("group1");+ Assert.IsTrue(discountProvider.IsAuthenticateGroup(customer));+ }++ [TestMethod()]+ public void IsAuthenticateGroupTest_False()+ {+ var discountProvider = new DiscountProviderTest(new List<string>() { "store2" }, new List<string> { "group1" });+ var customer = new Domain.Customers.Customer();+ customer.Groups.Add("group2");+ Assert.IsFalse(discountProvider.IsAuthenticateGroup(customer));+ }+ }+}\ No newline at end of filediff --git a/src/Tests/Grand.Infrastructure.Tests/Grand.Infrastructure.Tests.csproj b/src/Tests/Grand.Infrastructure.Tests/Grand.Infrastructure.Tests.csprojindex 13dfa3620..8db13e2f4 100644--- a/src/Tests/Grand.Infrastructure.Tests/Grand.Infrastructure.Tests.csproj+++ b/src/Tests/Grand.Infrastructure.Tests/Grand.Infrastructure.Tests.csproj@@ -16,6 +16,7 @@</ItemGroup><ItemGroup>+ <ProjectReference Include="..\..\Business\Grand.Business.Core\Grand.Business.Core.csproj" /><ProjectReference Include="..\..\Core\Grand.Domain\Grand.Domain.csproj" /><ProjectReference Include="..\..\Core\Grand.Infrastructure\Grand.Infrastructure.csproj" /><ProjectReference Include="..\..\Core\Grand.SharedKernel\Grand.SharedKernel.csproj" />