Skip to content

Commit 6c187f0

Browse files
committed
Add excepion test case for GetAll in profile service tests
1 parent 10aca36 commit 6c187f0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,21 @@ public void GetAll_WhenProfilesDoesNotExists_ShouldReturnNothing()
156156
Assert.Empty(profiles);
157157
}
158158

159+
/// <summary>
160+
/// Get all profiles.
161+
/// Should throw exception when repository throws exception.
162+
/// </summary>
163+
[Fact]
164+
public void GetAll_WhenRepositoryThrowsException_ShouldThrowException()
165+
{
166+
//Arrange
167+
_profileRepositoryMock.Setup(x => x.GetAll())
168+
.Throws(() => new Exception("Test exception"));
169+
170+
//Assert
171+
Assert.Throws<Exception>(() => _profileService.GetAll());
172+
}
173+
159174
#endregion
160175

161176
#region Get All Async function

0 commit comments

Comments
 (0)