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 plugin tests
supportb4fdbdf4dc48
diff --git a/src/Tests/Grand.Infrastructure.Tests/App_Data/index.txt b/src/Tests/Grand.Infrastructure.Tests/App_Data/index.txtnew file mode 100644index 000000000..5f282702b--- /dev/null+++ b/src/Tests/Grand.Infrastructure.Tests/App_Data/index.txt@@ -0,0 +1 @@+\ 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 8db13e2f4..68264ca4e 100644--- a/src/Tests/Grand.Infrastructure.Tests/Grand.Infrastructure.Tests.csproj+++ b/src/Tests/Grand.Infrastructure.Tests/Grand.Infrastructure.Tests.csproj@@ -21,4 +21,10 @@<ProjectReference Include="..\..\Core\Grand.Infrastructure\Grand.Infrastructure.csproj" /><ProjectReference Include="..\..\Core\Grand.SharedKernel\Grand.SharedKernel.csproj" /></ItemGroup>++ <ItemGroup>+ <None Update="App_Data\index.txt">+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>+ </None>+ </ItemGroup></Project>diff --git a/src/Tests/Grand.Infrastructure.Tests/Plugins/BasePluginTests.cs b/src/Tests/Grand.Infrastructure.Tests/Plugins/BasePluginTests.csnew file mode 100644index 000000000..9902ee672--- /dev/null+++ b/src/Tests/Grand.Infrastructure.Tests/Plugins/BasePluginTests.cs@@ -0,0 +1,49 @@+using Grand.Infrastructure.Tests.Plugins;+using Grand.SharedKernel.Extensions;+using Microsoft.VisualStudio.TestTools.UnitTesting;++namespace Grand.Infrastructure.Plugins.Tests+{+ [TestClass()]+ public class BasePluginTests+ {+ SampleBasePlugin sampleBasePlugin;+ public BasePluginTests()+ {+ CommonPath.BaseDirectory = NUnit.Framework.TestContext.CurrentContext.TestDirectory;+ sampleBasePlugin = new SampleBasePlugin();+ }++ [TestMethod()]+ public void ConfigurationUrlTest()+ {+ Assert.IsNotNull(sampleBasePlugin.ConfigurationUrl());+ }++ [TestMethod()]+ public async Task InstallTest()+ {+ await sampleBasePlugin.Install();+ var plugins = PluginExtensions.ParseInstalledPluginsFile(CommonPath.InstalledPluginsFilePath);+ Assert.IsNotNull(plugins);+ Assert.AreEqual("SamplePlugin", plugins.FirstOrDefault());+ }++ [TestMethod()]+ public async Task UninstallTest_WithInstall()+ {+ await sampleBasePlugin.Install();+ await sampleBasePlugin.Uninstall();+ var plugins = PluginExtensions.ParseInstalledPluginsFile(CommonPath.InstalledPluginsFilePath);+ Assert.AreEqual(0, plugins.Count());+ }++ [TestMethod()]+ public async Task UninstallTest()+ {+ await sampleBasePlugin.Uninstall();+ var plugins = PluginExtensions.ParseInstalledPluginsFile(CommonPath.InstalledPluginsFilePath);+ Assert.AreEqual(0, plugins.Count());+ }+ }+}\ No newline at end of filediff --git a/src/Tests/Grand.Infrastructure.Tests/Plugins/PluginExtensionsTests.cs b/src/Tests/Grand.Infrastructure.Tests/Plugins/PluginExtensionsTests.csnew file mode 100644index 000000000..2d80cbf53--- /dev/null+++ b/src/Tests/Grand.Infrastructure.Tests/Plugins/PluginExtensionsTests.cs@@ -0,0 +1,33 @@+using Grand.Infrastructure.Tests.Plugins;+using Grand.SharedKernel.Extensions;+using Microsoft.VisualStudio.TestTools.UnitTesting;++namespace Grand.Infrastructure.Plugins.Tests+{+ [TestClass()]+ public class PluginExtensionsTests+ {+ SampleBasePlugin sampleBasePlugin;+ public PluginExtensionsTests()+ {+ CommonPath.BaseDirectory = NUnit.Framework.TestContext.CurrentContext.TestDirectory;+ sampleBasePlugin = new SampleBasePlugin();+ }++ [TestMethod()]+ public async Task ParseInstalledPluginsFileTest()+ {+ await sampleBasePlugin.Install();+ var plugins = PluginExtensions.ParseInstalledPluginsFile(CommonPath.InstalledPluginsFilePath);+ Assert.IsNotNull(plugins);+ }++ [TestMethod()]+ public async Task SaveInstalledPluginsFileTest()+ {+ await PluginExtensions.SaveInstalledPluginsFile(new List<string> { "plugin1", "plugin2" }, CommonPath.InstalledPluginsFilePath);+ var plugins = PluginExtensions.ParseInstalledPluginsFile(CommonPath.InstalledPluginsFilePath);+ Assert.AreEqual(2, plugins.Count());+ }+ }+}\ No newline at end of filediff --git a/src/Tests/Grand.Infrastructure.Tests/Plugins/SampleBasePlugin.cs b/src/Tests/Grand.Infrastructure.Tests/Plugins/SampleBasePlugin.csnew file mode 100644index 000000000..45a54ce3b--- /dev/null+++ b/src/Tests/Grand.Infrastructure.Tests/Plugins/SampleBasePlugin.cs@@ -0,0 +1,30 @@+using Grand.Infrastructure.Plugins;++namespace Grand.Infrastructure.Tests.Plugins+{+ public class SampleBasePlugin : BasePlugin, IPlugin+ {+ private PluginInfo _pluginInfo;+ public SampleBasePlugin()+ {+ _pluginInfo = new PluginInfo() {+ Author = "grandnode",+ DisplayOrder = 0,+ FriendlyName = "sample plugin",+ SystemName = "SamplePlugin"+ };+ }+ public override PluginInfo PluginInfo {+ get {+ return _pluginInfo;+ }+ set {+ _pluginInfo = value;+ }+ }+ public override string ConfigurationUrl()+ {+ return "sample";+ }+ }+}