Created ExpiringTECNWorker
This commit is contained in:
@ -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