Skip to content

Commit 3de9db4

Browse files
committed
Add exception tests case for Update Async in tags service tests
1 parent 44da3ae commit 3de9db4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

BlogWebApp/Tests/Blog.ServicesTests/EntityServices/TagsServiceTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,23 @@ public async Task UpdateAsync_WhenCommentExists_ShouldReturnTag(string newTagTit
14771477
Assert.Equal(newTagTitle, tag.Title);
14781478
}
14791479

1480+
/// <summary>
1481+
/// Async Update tag.
1482+
/// Should throw exception when repository throws exception.
1483+
/// </summary>
1484+
[Fact]
1485+
public async Task UpdateAsync_WhenRepositoryThrowsException_ShouldThrowException()
1486+
{
1487+
//Arrange
1488+
var tag = SetupTagFixture().Create();
1489+
1490+
_tagsRepositoryMock.Setup(x => x.UpdateAsync(It.IsAny<Tag>()))
1491+
.ThrowsAsync(new Exception("Test exception"));
1492+
1493+
//Assert
1494+
await Assert.ThrowsAsync<Exception>(() => _tagsService.UpdateAsync(tag));
1495+
}
1496+
14801497
#endregion
14811498

14821499
#region Upadate Async Enumerable function

0 commit comments

Comments
 (0)