mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
small fix
This commit is contained in:
@@ -83,20 +83,6 @@ public class FriendshipControllerTests
|
|||||||
Assert.That(badRequestResult.Value, Is.EqualTo("Query cannot be empty"));
|
Assert.That(badRequestResult.Value, Is.EqualTo("Query cannot be empty"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public async Task Search_NotFound_IfThrowsSearchUsersException()
|
|
||||||
{
|
|
||||||
// Arrange
|
|
||||||
_friendsServiceMock.Setup(f => f.SearchUsersAsync(It.IsAny<string>(), It.IsAny<Guid>()))
|
|
||||||
.ThrowsAsync(new SearchUsersException(_fixture.Create<string>()));
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = await _controller.Search(_fixture.Create<string>());
|
|
||||||
// Assert
|
|
||||||
Assert.That(result, Is.InstanceOf<NotFoundObjectResult>());
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public async Task Search_StatusCode500_IfThrowsSomeException()
|
public async Task Search_StatusCode500_IfThrowsSomeException()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ public class FriendsRequestQueryController : Controller
|
|||||||
_logger.LogWarning(ex, ex.Message);
|
_logger.LogWarning(ex, ex.Message);
|
||||||
return Ok(new List<FriendshipDto>());
|
return Ok(new List<FriendshipDto>());
|
||||||
}
|
}
|
||||||
|
catch (UnauthorizedAccessException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, ex.Message);
|
||||||
|
return Forbid(ex.Message);
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, ex.Message);
|
_logger.LogError(ex, ex.Message);
|
||||||
@@ -70,6 +75,11 @@ public class FriendsRequestQueryController : Controller
|
|||||||
_logger.LogWarning(ex, ex.Message);
|
_logger.LogWarning(ex, ex.Message);
|
||||||
return Ok(new List<FriendshipDto>());
|
return Ok(new List<FriendshipDto>());
|
||||||
}
|
}
|
||||||
|
catch (UnauthorizedAccessException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, ex.Message);
|
||||||
|
return Forbid(ex.Message);
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, ex.Message);
|
_logger.LogError(ex, ex.Message);
|
||||||
|
|||||||
@@ -41,10 +41,10 @@ public class FriendshipController : Controller
|
|||||||
|
|
||||||
return Ok(response);
|
return Ok(response);
|
||||||
}
|
}
|
||||||
catch (SearchUsersException ex)
|
catch (UnauthorizedAccessException ex)
|
||||||
{
|
{
|
||||||
_logger.LogWarning(ex, ex.Message);
|
_logger.LogWarning(ex, ex.Message);
|
||||||
return NotFound(new { error = ex.Message });
|
return Forbid(ex.Message);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -69,6 +69,11 @@ public class FriendshipController : Controller
|
|||||||
_logger.LogError(ex, ex.Message);
|
_logger.LogError(ex, ex.Message);
|
||||||
return Ok(Array.Empty<UserDto>());
|
return Ok(Array.Empty<UserDto>());
|
||||||
}
|
}
|
||||||
|
catch (UnauthorizedAccessException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, ex.Message);
|
||||||
|
return Forbid(ex.Message);
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, ex.Message);
|
_logger.LogError(ex, ex.Message);
|
||||||
|
|||||||
@@ -61,15 +61,18 @@ public class FriendshipServiceTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void SearchUsersAsync_Throws_SearchUsersException_IfThrowsNotFoundByKeyException_String_Guid()
|
public async Task SearchUsersAsync_Returns_EmptyList_IfThrowsNotFoundByKeyException_String_Guid()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
_usersRepositoryMock
|
_usersRepositoryMock
|
||||||
.Setup(u => u.SearchPotentialFriendsAsync(It.IsAny<Guid>(), It.IsAny<string>()))
|
.Setup(u => u.SearchPotentialFriendsAsync(It.IsAny<Guid>(), It.IsAny<string>()))
|
||||||
.ThrowsAsync(new NotFoundByKeyException<(string,Guid)>(("test",Guid.NewGuid()),"test"));
|
.ThrowsAsync(new NotFoundByKeyException<(string,Guid)>(("test",Guid.NewGuid()),"test"));
|
||||||
|
|
||||||
// Axt & Assert
|
// Act
|
||||||
Assert.ThrowsAsync<SearchUsersException>(async () => await _service.SearchUsersAsync("test", Guid.NewGuid()));
|
var users = await _service.SearchUsersAsync("test", Guid.NewGuid());
|
||||||
|
|
||||||
|
// & Assert
|
||||||
|
Assert.That(users, Is.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ public class FriendshipService : IFriendshipService
|
|||||||
}
|
}
|
||||||
catch (NotFoundByKeyException<(string, Guid)> ex)
|
catch (NotFoundByKeyException<(string, Guid)> ex)
|
||||||
{
|
{
|
||||||
throw new SearchUsersException(
|
return [];
|
||||||
$"Users with given query: \"{query}\" for user with id {currentId} was not found", ex);
|
|
||||||
}
|
}
|
||||||
catch (NotFoundByKeyException<Guid> ex)
|
catch (NotFoundByKeyException<Guid> ex)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user