|
1 | 1 | using MailCore.Application.Commands.Emails.SendEmail; |
2 | 2 | using MailCore.Application.DTOs.Emails; |
3 | 3 | using MailCore.Application.Emails; |
| 4 | +using MailCore.Application.Exceptions; |
4 | 5 | using MailCore.Application.Interfaces.Services; |
5 | 6 | using MailCore.Domain.Entities; |
6 | 7 | using MailCore.Domain.Enums; |
@@ -106,35 +107,35 @@ public async Task Handle_AddsMailRecipientForEachToAddress() |
106 | 107 | // ?? Failure paths ???????????????????????????????????????????????????????? |
107 | 108 |
|
108 | 109 | [Fact] |
109 | | - public async Task Handle_SenderNotFound_ThrowsKeyNotFoundException() |
| 110 | + public async Task Handle_SenderNotFound_ThrowsNotFoundException() |
110 | 111 | { |
111 | 112 | _userRepo.Setup(r => r.GetByIdAsync(_userId, default)).ReturnsAsync((User?)null); |
112 | 113 |
|
113 | | - await Assert.ThrowsAsync<KeyNotFoundException>( |
| 114 | + await Assert.ThrowsAsync<NotFoundException>( |
114 | 115 | () => _sut.Handle(ValidCommand(), default)); |
115 | 116 |
|
116 | 117 | _emailRepo.Verify(r => r.AddAsync(It.IsAny<Email>(), default), Times.Never); |
117 | 118 | } |
118 | 119 |
|
119 | 120 | [Fact] |
120 | | - public async Task Handle_ThreadNotFound_ThrowsKeyNotFoundException() |
| 121 | + public async Task Handle_ThreadNotFound_ThrowsNotFoundException() |
121 | 122 | { |
122 | 123 | var threadId = Guid.NewGuid(); |
123 | 124 | _userRepo.Setup(r => r.GetByIdAsync(_userId, default)).ReturnsAsync(_sender); |
124 | 125 | _threadRepo.Setup(r => r.GetByIdAsync(threadId, default)).ReturnsAsync((Domain.Entities.Thread?)null); |
125 | 126 |
|
126 | | - await Assert.ThrowsAsync<KeyNotFoundException>( |
| 127 | + await Assert.ThrowsAsync<NotFoundException>( |
127 | 128 | () => _sut.Handle(ValidCommand(threadId), default)); |
128 | 129 | } |
129 | 130 |
|
130 | 131 | [Fact] |
131 | | - public async Task Handle_RecipientNotFound_ThrowsKeyNotFoundException() |
| 132 | + public async Task Handle_RecipientNotFound_ThrowsNotFoundException() |
132 | 133 | { |
133 | 134 | _userRepo.Setup(r => r.GetByIdAsync(_userId, default)).ReturnsAsync(_sender); |
134 | 135 | _userRepo.Setup(r => r.GetByEmailAsync("recipient@example.com", default)) |
135 | 136 | .ReturnsAsync((User?)null); |
136 | 137 |
|
137 | | - await Assert.ThrowsAsync<KeyNotFoundException>( |
| 138 | + await Assert.ThrowsAsync<NotFoundException>( |
138 | 139 | () => _sut.Handle(ValidCommand(), default)); |
139 | 140 | } |
140 | 141 | } |
0 commit comments