Added training reminder worker
This commit is contained in:
@ -29,7 +29,7 @@ internal class ECNServiceTests {
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetExpiringTECNsWithDbErrorShouldThrowException() {
|
||||
public void GetExpiringTECNsWithDbErrorShouldThrowException() {
|
||||
_mockDalService.Setup(d => d.QueryAsync<ECN>(It.IsAny<string>())).ThrowsAsync(new Exception());
|
||||
|
||||
_ecnService = new ECNService(_mockLogger.Object, _mockDalService.Object);
|
||||
@ -38,7 +38,7 @@ internal class ECNServiceTests {
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetExpiredTECNsWithDbErrorShouldThrowException() {
|
||||
public void GetExpiredTECNsWithDbErrorShouldThrowException() {
|
||||
_mockDalService.Setup(d => d.QueryAsync<ECN>(It.IsAny<string>())).ThrowsAsync(new Exception());
|
||||
|
||||
_ecnService = new ECNService(_mockLogger.Object, _mockDalService.Object);
|
||||
@ -215,7 +215,7 @@ internal class ECNServiceTests {
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetTECNNotificationUserEmailsDbErrorShouldThrowException() {
|
||||
public void GetTECNNotificationUserEmailsDbErrorShouldThrowException() {
|
||||
_mockDalService.Setup(d => d.QueryAsync<string>(It.IsAny<string>())).Throws(new Exception());
|
||||
|
||||
_ecnService = new ECNService(_mockLogger.Object, _mockDalService.Object);
|
||||
@ -238,4 +238,52 @@ internal class ECNServiceTests {
|
||||
|
||||
Assert.That(actualEmails.Count(), Is.EqualTo(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetEcnByNumberWithInvalidNumberShouldThrowException() {
|
||||
_ecnService = new ECNService(_mockLogger.Object, _mockDalService.Object);
|
||||
|
||||
Assert.ThrowsAsync<ArgumentException>(async Task () => await _ecnService.GetEcnByNumber(0));
|
||||
|
||||
Assert.ThrowsAsync<ArgumentException>(async Task () => await _ecnService.GetEcnByNumber(-4));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetEcnByNumberDbErrorShouldThrowException() {
|
||||
_mockDalService.Setup(d => d.QueryAsync<ECN>(It.IsAny<string>())).Throws(new Exception());
|
||||
|
||||
_ecnService = new ECNService(_mockLogger.Object, _mockDalService.Object);
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async Task () => await _ecnService.GetEcnByNumber(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetEcnByNumberEcnNotFoundShouldThrowException() {
|
||||
IEnumerable<ECN> expectedEcns = new List<ECN>();
|
||||
|
||||
_mockDalService.Setup(d => d.QueryAsync<ECN>(It.IsAny<string>())).Returns(Task.FromResult(expectedEcns));
|
||||
|
||||
_ecnService = new ECNService(_mockLogger.Object, _mockDalService.Object);
|
||||
|
||||
Assert.ThrowsAsync<Exception>(async Task () => await _ecnService.GetEcnByNumber(8));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetEcnByNumberShouldReturnExpectedEcn() {
|
||||
IEnumerable<ECN> expectedEcns = new List<ECN>() {
|
||||
new ECN() {
|
||||
ECNNumber = 1,
|
||||
OriginatorID = 1,
|
||||
Title = "title"
|
||||
}
|
||||
};
|
||||
|
||||
_mockDalService.Setup(d => d.QueryAsync<ECN>(It.IsAny<string>())).Returns(Task.FromResult(expectedEcns));
|
||||
|
||||
_ecnService = new ECNService(_mockLogger.Object, _mockDalService.Object);
|
||||
|
||||
ECN actualEcn = await _ecnService.GetEcnByNumber(9);
|
||||
|
||||
Assert.That(expectedEcns.First(), Is.EqualTo(actualEcn));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user