Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

WebTest.cs

using Microsoft.AspNetCore.Hosting;
using Moq;
using Nop.Core;
using Nop.Core.Infrastructure;
using Nop.Services.Plugins;
using Nop.Tests.Nop.Web.Tests.Public;
using NUnit.Framework;

namespace Nop.Tests.Nop.Web.Tests;

[TestFixture]
public abstract class WebTest : BaseNopTest
{
    protected WebTest()
    {
        //init plugins
        InitPlugins();
    }

    private void InitPlugins()
    {
        var webHostEnvironment = new Mock();
        webHostEnvironment.Setup(x => x.ContentRootPath).Returns(System.Reflection.Assembly.GetExecutingAssembly().Location);
        webHostEnvironment.Setup(x => x.WebRootPath).Returns(System.IO.Directory.GetCurrentDirectory());
        CommonHelper.DefaultFileProvider = new NopFileProvider(webHostEnvironment.Object);

        Singleton.Instance = new PluginsInfo(CommonHelper.DefaultFileProvider)
        {
            PluginDescriptors = new List<(PluginDescriptor, bool)>
            {
                (new PluginDescriptor
                {
                    PluginType = typeof(TestWidgetPlugin),
                    SystemName = "TestWidgetPlugin",
                    FriendlyName = "Test widget plugin",
                    Installed = true,
                    ReferencedAssembly = typeof(TestWidgetPlugin).Assembly
                }, true)
            }
        };
    }
}