Adding
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using LCU.API.Collections.RepoApi;
|
||||
using LCU.API.Collections.RepoApi.Configuration;
|
||||
using LCU.API.Collections.RepoApi.Services;
|
||||
using LCU.Shared.Collections.RepoApiLib.Models;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
namespace LCU.API.Collections.RepoApiTests
|
||||
{
|
||||
public class EmailerTest
|
||||
{
|
||||
private readonly Mock<IHttpClientFactory> _mockHttpClientFactory;
|
||||
private readonly Mock<IEventAlertService> _mockEventAlertService;
|
||||
private readonly IEmailer emailer;
|
||||
|
||||
public EmailerTest()
|
||||
{
|
||||
var mockConsumerConfiguration = new Mock<RepoApiConfiguration>();
|
||||
_mockHttpClientFactory = new Mock<IHttpClientFactory>();
|
||||
_mockEventAlertService = new Mock<IEventAlertService>();
|
||||
emailer = new Emailer(_mockHttpClientFactory.Object, mockConsumerConfiguration.Object,
|
||||
_mockEventAlertService.Object);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async System.Threading.Tasks.Task Update_Hourly_Alert_Email_SuccessAsync()
|
||||
{
|
||||
var testAlerts = new List<EventAlert>()
|
||||
{
|
||||
new EventAlert()
|
||||
{
|
||||
DateAdded = DateTime.Now,
|
||||
AccountNo = "123456-134",
|
||||
RepoId = 777777,
|
||||
Message = "Alert Message"
|
||||
}
|
||||
};
|
||||
|
||||
_mockEventAlertService.Setup(service =>
|
||||
service.ListWithinDateRange(It.IsAny<DateTime>(), It.IsAny<DateTime>()))
|
||||
.ReturnsAsync(testAlerts);
|
||||
|
||||
var endTime = DateTime.Now;
|
||||
await emailer.SendAlertSummaryEmailWithEndTime(endTime);
|
||||
|
||||
_mockEventAlertService.Verify(
|
||||
foo => foo.ListWithinDateRange(It.IsAny<DateTime>(), It.IsAny<DateTime>()), Times.Once);
|
||||
Assert.NotNull(emailer);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user