Files
forkmessager/backend/Tests/Users/UnitTests/UpdateProfileCommandHandlerTests.cs

36 lines
1.1 KiB
C#

using FluentAssertions;
using Knot.Modules.Profiles.Application.Profiles.UpdateProfile;
using Knot.Shared.Kernel;
using NSubstitute;
using Xunit;
using System;
using System.Threading;
using System.Threading.Tasks;
using Knot.Contracts.Profiles.Domain;
using Knot.Contracts.Profiles.Application.DTOs;
namespace Knot.Modules.Profiles.UnitTests;
public class UpdateProfileCommandHandlerTests
{
private readonly IProfileRepository _profileRepository;
private readonly UpdateProfileCommandHandler _handler;
public UpdateProfileCommandHandlerTests()
{
_profileRepository = Substitute.For<IProfileRepository>();
_handler = new UpdateProfileCommandHandler(_profileRepository);
}
[Fact]
public async Task Handle_ShouldReturnError_WhenProfileNotFound()
{
var command = new UpdateProfileCommand(Guid.NewGuid(), "FirstName", "Bio", null, null);
_profileRepository.GetAsync(command.UserId, Arg.Any<CancellationToken>()).Returns((UserProfileDto?)null);
var result = await _handler.Handle(command, CancellationToken.None);
result.IsFailure.Should().BeTrue();
}
}