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
using Grand.Business.Core.Events.Customers;
using Grand.Business.Core.Interfaces.Customers;
using Grand.Business.Customers.Events.Handlers;
using Grand.Domain.Customers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
namespace Grand.Business.Customers.Tests.Handler;
[TestClass]
public class CustomerLoggedInNotificationHandlerTests
{
private Mock<ICustomerService> _cumstomerServiceMock;
private CustomerLoggedInEventHandler _handler;
[TestInitialize]
public void Init()
{
_cumstomerServiceMock = new Mock<ICustomerService>();
_handler = new CustomerLoggedInEventHandler(_cumstomerServiceMock.Object);
}
[TestMethod]
public async Task HandleTest()
{
//Arrange
var customer = new Customer {
FailedLoginAttempts = 1,
CannotLoginUntilDateUtc = DateTime.Now
};
//Act
await _handler.Handle(new CustomerLoggedInEvent(customer), CancellationToken.None);
//Assert
Assert.AreEqual(0, customer.FailedLoginAttempts);
Assert.IsNull(customer.CannotLoginUntilDateUtc);
_cumstomerServiceMock.Verify(c => c.UpdateCustomerLastLoginDate(customer), Times.Once);
}
}