adding
This commit is contained in:
+56
@@ -0,0 +1,56 @@
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
using LCU.API.Internal.Document.Services;
|
||||
using LCU.API.Internal.DocumentLib.DataAccess;
|
||||
using LCU.API.Internal.NotificationsApiLib.Models;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace LCU.API.Internal.DocumentTest.Services;
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user