public GetFriendCommandResult Handler(GetFriendCommand command) { command.Validate(); if (command.Invalid) { return(new GetFriendCommandResult(false, null, command.Notifications.ToList())); } var friendsFormatted = FormatFriends(friendRepository.GetAll().ToList(), command.NumberOfCloserFriends); return(new GetFriendCommandResult(true, friendsFormatted.Select(f => new FriendCommandResult(f.Name, f.CloseFriends.ToList())).ToList(), new Message(messageType: MessageType.Information, description: "Busca realizada com sucesso!!!"))); }
public void ShouldThrowMessageFriendNotFound() { GenerateMock(); _friendQueryMock.Setup(x => x.GetAsync(It.IsAny <Guid>(), It.IsAny <CancellationToken>())); var handler = GetCommandHandler(); var command = new GetFriendCommand(Guid.NewGuid()); FluentActions.Invoking(async() => await handler.Handle(command, default)) .Should() .Throw <NotFoundException>().WithMessage("Friend not found!"); _friendQueryMock .Verify(x => x.GetAsync(It.Is <Guid>(f => f.Equals(command.Id)), It.IsAny <CancellationToken>())); }