94 lines
2.3 KiB
C#
94 lines
2.3 KiB
C#
using Heimdall.Domain.Entities;
|
|||
|
|
using Shouldly;
|
||
|
|
|
||
|
|
namespace Heimdall.Domain.Tests.Entities;
|
||
|
|
|
||
|
|
public class PersonTests
|
||
|
|
{
|
||
|
|
[Fact]
|
||
|
|
public void Create_person_should_set_properties()
|
||
|
|
{
|
||
|
|
var person = new Person("John Doe", "family");
|
||
|
|
|
||
|
|
person.DisplayName.ShouldBe("John Doe");
|
||
|
|
person.Category.ShouldBe("family");
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void Create_person_without_category()
|
||
|
|
{
|
||
|
|
var person = new Person("Unknown");
|
||
|
|
|
||
|
|
person.Category.ShouldBeNull();
|
||
|
|
person.IsWatchlisted.ShouldBeFalse();
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void Update_should_change_all_properties()
|
||
|
|
{
|
||
|
|
var person = new Person("Old Name", "family");
|
||
|
|
|
||
|
|
person.Update("New Name", "Some notes", "watchlist", true);
|
||
|
|
|
||
|
|
person.DisplayName.ShouldBe("New Name");
|
||
|
|
person.Notes.ShouldBe("Some notes");
|
||
|
|
person.Category.ShouldBe("watchlist");
|
||
|
|
person.IsWatchlisted.ShouldBeTrue();
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void SetPhoto_should_update_photo_url()
|
||
|
|
{
|
||
|
|
var person = new Person("John Doe");
|
||
|
|
|
||
|
|
person.SetPhoto("https://example.com/photo.jpg");
|
||
|
|
|
||
|
|
person.PhotoUrl.ShouldBe("https://example.com/photo.jpg");
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void AddFace_should_add_to_collection()
|
||
|
|
{
|
||
|
|
var person = new Person("John Doe");
|
||
|
|
var face = new KnownFace(person.Id, [0.1f, 0.2f, 0.3f]);
|
||
|
|
|
||
|
|
person.AddFace(face);
|
||
|
|
|
||
|
|
person.Faces.Count.ShouldBe(1);
|
||
|
|
person.Faces.ShouldContain(face);
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void Faces_collection_should_be_readonly()
|
||
|
|
{
|
||
|
|
var person = new Person("John Doe");
|
||
|
|
|
||
|
|
person.Faces.ShouldBeEmpty();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public class KnownFaceTests
|
||
|
|
{
|
||
|
|
[Fact]
|
||
|
|
public void Create_knownface_should_set_properties()
|
||
|
|
{
|
||
|
|
var personId = Guid.NewGuid();
|
||
|
|
var embedding = new float[] { 0.1f, 0.2f, 0.3f, 0.4f };
|
||
|
|
|
||
|
|
var face = new KnownFace(personId, embedding, "thumb.jpg", "evt-123");
|
||
|
|
|
||
|
|
face.PersonId.ShouldBe(personId);
|
||
|
|
face.Embedding.ShouldBe(embedding);
|
||
|
|
face.ThumbnailUrl.ShouldBe("thumb.jpg");
|
||
|
|
face.SourceEventId.ShouldBe("evt-123");
|
||
|
|
}
|
||
|
|
|
||
|
|
[Fact]
|
||
|
|
public void Create_knownface_minimal()
|
||
|
|
{
|
||
|
|
var face = new KnownFace(Guid.NewGuid(), [0.5f, 0.6f]);
|
||
|
|
|
||
|
|
face.ThumbnailUrl.ShouldBeNull();
|
||
|
|
face.SourceEventId.ShouldBeNull();
|
||
|
|
}
|
||
|
|
}
|