Files
monorepo/LCU.API.Internal.DocumentIngestor/LCU.API.Internal.DocumentIngestorTests/Services/MicroApiServices/NotificationApiServiceTest.cs
T
2026-03-25 14:50:13 -05:00

57 lines
1.6 KiB
C#

using LCU.API.Internal.DocumentIngestor.DataAccess;
using LCU.API.Internal.DocumentIngestor.Services.MicroApiServices;
using LCU.Library.Internal.Exceptions;
using LCU.Library.Internal.NotificationsModels.Models;
using Moq;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace LCU.API.Internal.DocumentIngestorTests.Services.MicroApiServices;
public class NotificationApiServiceTest
{
private NotificationApiService _notificationApiService;
private Mock<INotificationApiDao> _mockNotificationApiDao;
[SetUp]
public void Setup()
{
_mockNotificationApiDao = new Mock<INotificationApiDao>();
_notificationApiService = new NotificationApiService(_mockNotificationApiDao.Object);
}
[Test]
public void SendEmailAsync_Exception()
{
_mockNotificationApiDao.Setup(x => x.SendEmailAsync(It.IsAny<EmailRequest>()))
.ThrowsAsync(new Exception("Error"));
var request = new EmailRequest()
{
Subject = "",
Body = "",
Recipient = new List<string>(new string[] { "" })
};
Assert.ThrowsAsync<ServiceException>(async () => await _notificationApiService.SendEmailAsync(request));
_mockNotificationApiDao.Verify(x => x.SendEmailAsync(It.IsAny<EmailRequest>()), Times.Once);
}
[Test]
public async Task SendEmailAsync_Return()
{
_mockNotificationApiDao.Setup(x => x.SendEmailAsync(It.IsAny<EmailRequest>()));
var request = new EmailRequest()
{
Subject = "",
Body = "",
Recipient = new List<string>(new string[] { "" })
};
await _notificationApiService.SendEmailAsync(request);
_mockNotificationApiDao.Verify(x => x.SendEmailAsync(It.IsAny<EmailRequest>()), Times.Once);
}
}