Created ExpiringTECNWorker
This commit is contained in:
@ -142,7 +142,6 @@ internal class ECNServiceTests {
|
||||
Assert.That(actual.Count(), Is.EqualTo(3));
|
||||
}
|
||||
|
||||
// Test when responses include extension dates
|
||||
[Test]
|
||||
public async Task GetExpiringTECNsWithExtensionsFromDbShouldReturnSameResults() {
|
||||
IEnumerable<ECN> ecns = new List<ECN>() {
|
||||
@ -214,4 +213,29 @@ internal class ECNServiceTests {
|
||||
|
||||
Assert.That(actual.Count(), Is.EqualTo(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetTECNNotificationUserEmailsDbErrorShouldThrowException() {
|
||||
_mockDalService.Setup(d => d.QueryAsync<string>(It.IsAny<string>())).Throws(new Exception());
|
||||
|
||||
_ecnService = new ECNService(_mockLogger.Object, _mockDalService.Object);
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async Task () => await _ecnService.GetTECNNotificationUserEmails());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetTECNNotificationUserEmailsShouldReturnExpectedUserEmails() {
|
||||
IEnumerable<string> userEmails = new List<string>() {
|
||||
"fake1@email.com",
|
||||
"fake2@email.com"
|
||||
};
|
||||
|
||||
_mockDalService.Setup(d => d.QueryAsync<string>(It.IsAny<string>())).Returns(Task.FromResult(userEmails));
|
||||
|
||||
_ecnService = new ECNService(_mockLogger.Object, _mockDalService.Object);
|
||||
|
||||
IEnumerable<string> actualEmails = await _ecnService.GetTECNNotificationUserEmails();
|
||||
|
||||
Assert.That(actualEmails.Count(), Is.EqualTo(2));
|
||||
}
|
||||
}
|
||||
|
@ -443,4 +443,33 @@ internal class UserServiceTests {
|
||||
|
||||
Assert.False(actual);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetUserEmailWithInvalidUserIdShouldThrowException() {
|
||||
_userService = new UserService(MOCK_LOGGER, _mockDalService.Object);
|
||||
|
||||
Assert.ThrowsAsync<ArgumentException>(async Task() => await _userService.GetUserEmail(-1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetUserEmailWithDbErrorShouldThrowException() {
|
||||
_mockDalService.Setup(d => d.QueryAsync<string>(It.IsAny<string>())).Throws(new Exception());
|
||||
|
||||
_userService = new UserService(MOCK_LOGGER, _mockDalService.Object);
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async Task() => await _userService.GetUserEmail(3));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetUserEmailShouldReturnExpectedEmail() {
|
||||
IEnumerable<string> emailsFromDb = new List<string>() { "user@email.com" };
|
||||
|
||||
_mockDalService.Setup(d => d.QueryAsync<string>(It.IsAny<string>())).Returns(Task.FromResult(emailsFromDb));
|
||||
|
||||
_userService = new UserService(MOCK_LOGGER, _mockDalService.Object);
|
||||
|
||||
string actualEmail = await _userService.GetUserEmail(5);
|
||||
|
||||
Assert.That(actualEmail, Is.EqualTo(emailsFromDb.First()));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user