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.

705 B
Raw Blame
using Grand.Infrastructure.Caching;
using Grand.Module.ScheduledTasks.BackgroundServices;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;

namespace Grand.Modules.Tests.Services.BackgroundService;

[TestClass]
public class ClearCacheScheduleTaskTests
{
    private Mock<ICacheBase> _cacheMock;
    private ClearCacheScheduleTask _task;

    [TestInitialize]
    public void Init()
    {
        _cacheMock = new Mock<ICacheBase>();
        _task = new ClearCacheScheduleTask(_cacheMock.Object);
    }

    [TestMethod]
    public async Task Execute_InvokeExpectedMethod()
    {
        await _task.Execute();
        _cacheMock.Verify(c => c.Clear(It.IsAny<bool>()), Times.Once);
    }
}