using FluentAssertions; using MediatR; using Moq; using Nashel.Modules.Reputation.Application.Commands; using Nashel.Modules.Reputation.Domain.Entities; using Nashel.Modules.Reputation.Domain.Repositories; using Xunit; namespace Nashel.Modules.Reputation.Tests.Application; public class ReviewApplicationTests { private readonly Mock _repositoryMock; private readonly Mock _mediatorMock; private readonly CreateReviewHandler _handler; public ReviewApplicationTests() { _repositoryMock = new Mock(); _mediatorMock = new Mock(); _handler = new CreateReviewHandler(_repositoryMock.Object, _mediatorMock.Object); } [Fact] public async Task СозданиеОтзыва_Должно_Сохранить_Отзыв_И_Опубликовать_События() { // 1. Arrange var command = new CreateReviewCommand( OrderId: Guid.NewGuid(), AuthorId: Guid.NewGuid(), TargetId: Guid.NewGuid(), Rating: 5, Text: "Отличный опыт!" ); // 2. Act var result = await _handler.Handle(command, CancellationToken.None); // 3. Assert result.Should().NotBeEmpty(); _repositoryMock.Verify(r => r.AddAsync(It.IsAny(), It.IsAny()), Times.Once); _mediatorMock.Verify(m => m.Publish(It.IsAny(), It.IsAny()), Times.AtLeastOnce); } }