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.

1022 B
Raw Blame
using Grand.Business.Core.Interfaces.Customers;
using Grand.Domain.Common;
using Grand.Module.ScheduledTasks.BackgroundServices;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;

namespace Grand.Modules.Tests.Services.BackgroundService;

[TestClass]
public class DeleteGuestsScheduleTaskTests
{
    private Mock<ICustomerService> _customerServiceMock;
    private SystemSettings _settings;
    private DeleteGuestsScheduleTask _task;

    [TestInitialize]
    public void Init()
    {
        _customerServiceMock = new Mock<ICustomerService>();
        _settings = new SystemSettings();
        _task = new DeleteGuestsScheduleTask(_customerServiceMock.Object, _settings);
    }

    [TestMethod]
    public async Task Execute_InovkeExpectedMethod()
    {
        _settings.DeleteGuestTaskOlderThanMinutes = 0;
        await _task.Execute();
        _customerServiceMock.Verify(
            c => c.DeleteGuestCustomers(It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<bool>()), Times.Once);
    }
}