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 _mockHttpClientFactory; private readonly Mock _mockEventAlertService; private readonly IEmailer emailer; public EmailerTest() { var mockConsumerConfiguration = new Mock(); _mockHttpClientFactory = new Mock(); _mockEventAlertService = new Mock(); 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() { new EventAlert() { DateAdded = DateTime.Now, AccountNo = "123456-134", RepoId = 777777, Message = "Alert Message" } }; _mockEventAlertService.Setup(service => service.ListWithinDateRange(It.IsAny(), It.IsAny())) .ReturnsAsync(testAlerts); var endTime = DateTime.Now; await emailer.SendAlertSummaryEmailWithEndTime(endTime); _mockEventAlertService.Verify( foo => foo.ListWithinDateRange(It.IsAny(), It.IsAny()), Times.Once); Assert.NotNull(emailer); } } }