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.

1007 B
Raw Blame
using Grand.Business.Authentication.Events;
using Grand.Data;
using Grand.Data.Tests.MongoDb;
using Grand.Domain.Customers;
using Grand.Infrastructure.Events;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Grand.Business.Authentication.Tests.Events;

[TestClass]
public class CustomerDeletedEventHandlerTests
{
    private CustomerDeletedEventHandler _handler;
    private IRepository<ExternalAuthentication> _repository;

    [TestInitialize]
    public void Init()
    {
        _repository = new MongoDBRepositoryTest<ExternalAuthentication>();
        _handler = new CustomerDeletedEventHandler(_repository);
    }

    [TestMethod]
    public async Task HandleTest()
    {
        //Arrange
        await _repository.InsertAsync(new ExternalAuthentication { CustomerId = "1" });
        //Act
        await _handler.Handle(new EntityDeleted<Customer>(new Customer { Id = "1" }), CancellationToken.None);
        //Assert
        Assert.AreEqual(0, _repository.Table.Count());
    }
}