using Heimdall.Application.Common; using Heimdall.Application.Persons.Queries.GetFaces; using Heimdall.Application.Tests.Common; using Heimdall.Domain.Entities; using NSubstitute; using Microsoft.EntityFrameworkCore; namespace Heimdall.Application.Tests.Handlers.Persons; public class GetFacesHandlerTests { [Fact] public async Task Get_faces_should_return_faces() { var personId = Guid.NewGuid(); var faces = new List { new(personId, [0.1f], "thumb1.jpg", "evt-1"), new(personId, [0.2f], "thumb2.jpg", "evt-2"), }; var context = Substitute.For(); context.KnownFaces.Returns(MockDbSetHelper.CreateFor(faces)); var handler = new GetFacesQueryHandler(context); var result = await handler.Handle(new GetFacesQuery(personId), CancellationToken.None); result.IsSuccess.ShouldBeTrue(); result.Data.ShouldNotBeNull(); result.Data.Count.ShouldBe(2); } [Fact] public async Task Get_faces_empty_should_return_empty_list() { var context = Substitute.For(); context.KnownFaces.Returns(MockDbSetHelper.CreateFor()); var handler = new GetFacesQueryHandler(context); var result = await handler.Handle(new GetFacesQuery(Guid.NewGuid()), CancellationToken.None); result.IsSuccess.ShouldBeTrue(); result.Data.ShouldBeEmpty(); } }