Skip to content

Commit 5b0d7af

Browse files
committed
Add exception tests case for Update Async Enumerable in tags service tests
1 parent 3de9db4 commit 5b0d7af

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,6 +1582,27 @@ public async Task UpdateAsyncEnumerable_WhenCommentExists_ShouldReturnComment(st
15821582
}
15831583
}
15841584

1585+
/// <summary>
1586+
/// Update Async Enumerable tags.
1587+
/// Should throw exception when repository throws exception.
1588+
/// </summary>
1589+
[Fact]
1590+
public async Task UpdateAsyncEnumerable_WhenRepositoryThrowsException_ShouldThrowException()
1591+
{
1592+
//Arrange
1593+
var random = new Random();
1594+
var itemsCount = random.Next(100);
1595+
var tags = SetupTagFixture()
1596+
.CreateMany(itemsCount)
1597+
.ToList();
1598+
1599+
_tagsRepositoryMock.Setup(x => x.UpdateAsync(It.IsAny<IEnumerable<Tag>>()))
1600+
.Throws(new Exception("Test exception"));
1601+
1602+
//Assert
1603+
await Assert.ThrowsAsync<Exception>(() => _tagsService.UpdateAsync(tags));
1604+
}
1605+
15851606
#endregion
15861607

15871608
#endregion

0 commit comments

Comments
 (0)