technical edits

This commit is contained in:
Artemy
2025-12-12 17:23:01 +07:00
parent bf2aca40d3
commit 7e6f914878
23 changed files with 461 additions and 114 deletions
@@ -43,7 +43,6 @@ public class AuthServiceTests
_accountService = new AuthService(
_usersRepositoryMock.Object,
_jwtServiceMock.Object,
_passwordHasherMock.Object,
_adminsRepositoryMock.Object,
_usernameValidatorMock.Object
@@ -1,5 +1,4 @@
using AutoFixture;
using Govor.Application.Exceptions.FriendsService;
using Govor.Application.Interfaces.Friends;
using Govor.Application.Services.Friends;
using Govor.Core.Models;
@@ -115,12 +114,14 @@ public class FriendshipServiceTests
public void SearchUsersAsync_Throws_UnauthorizedAccessException_IfThrowsSomeExceptionInFriendshipsRepository()
{
// Arrange
_friendshipsRepositoryMock
.Setup(u => u.FindByUserIdAsync(It.IsAny<Guid>()))
_usersRepositoryMock
.Setup(u => u.SearchPotentialFriendsAsync(It.IsAny<Guid>(), "test"))
.ThrowsAsync(new Exception("test"));
// Act & Assert
Assert.ThrowsAsync<UnauthorizedAccessException>(async () => await _service.SearchUsersAsync("test", Guid.NewGuid()));
Assert.ThrowsAsync<UnauthorizedAccessException>(
async () => await _service.SearchUsersAsync("test", Guid.NewGuid())
);
}
// GetFriendsAsync
@@ -31,7 +31,7 @@ public class AccesserToDownloadMediaServiceTests
_groupId = Guid.NewGuid();
_mediaFileId = Guid.NewGuid();
// Áàçîâîå ñîîáùåíèå è ìåäèà
//
var message = new Message
{
Id = Guid.NewGuid(),
@@ -170,7 +170,7 @@ public class AccesserToDownloadMediaServiceTests
}
[Test]
public async Task HasAccessAsync_ReturnsFalse_ForOtherUserAvatar()
public async Task HasAccessAsync_ReturnsTrue_ForOtherUserAvatar()
{
var avatarMedia = new MediaFile
{
@@ -188,7 +188,7 @@ public class AccesserToDownloadMediaServiceTests
await _dbContext.SaveChangesAsync();
var result = await _accesser.HasAccessAsync(avatarMedia.Id, _userId);
Assert.That(result, Is.False);
Assert.That(result, Is.True);
}
[Test]
@@ -275,7 +275,7 @@ public class AccesserToDownloadMediaServiceTests
MineType = "image/png",
MediaType = MediaType.Image,
UploaderId = _userId,
OwnerType = (MediaOwnerType)999, // íåèçâåñòíûé òèï
OwnerType = (MediaOwnerType)999, //
DateCreated = DateTime.UtcNow
};
@@ -1,6 +1,7 @@
using Govor.Application.Services;
using Govor.Core.Models.Users;
using Govor.Core.Repositories.Users;
using Govor.Data.Repositories.Exceptions;
using Microsoft.Extensions.Logging;
using Moq;
@@ -64,7 +65,19 @@ public class ProfileServiceTests
Assert.ThrowsAsync<NullReferenceException>(() =>
_service.GetUserProfileAsync(Guid.NewGuid()));
}
[Test]
public void GetUserProfileAsync_ThrowsNotFoundException_WhenNotFoundByKeyException()
{
// Arrange
var userId = Guid.NewGuid();
_mockUsersRepo.Setup(r => r.FindByIdAsync(It.IsAny<Guid>()))
.ThrowsAsync(new NotFoundByKeyException<Guid>(userId));
// Act + Assert
Assert.ThrowsAsync<NotFoundException>(() =>
_service.GetUserProfileAsync(userId));
}
// ---------- SetDescription ----------
[Test]