Timeline bands and month mapping, saved views (validation and a round trip through the settings table), the mass actions bar's targets and reasons, remote cards and their place among the pages, the CSV list and the delete dry run's confirmation. --capture writes library-timeline, library-mass, library-delete and library-remote in both themes (LibraryScenes), the sample data saves two views, and a Windows smoke test renders each scene and checks the bar, the typed confirmation and the saved views. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
115 lines
6.1 KiB
C#
115 lines
6.1 KiB
C#
using Titano.App.Library;
|
|
using Titano.Core.Model;
|
|
using Titano.Data.Repositories;
|
|
using Titano.Data.Sync;
|
|
using Titano.Protocol;
|
|
using Titano.Testing;
|
|
|
|
namespace Titano.App.Tests.Library;
|
|
|
|
/// <summary>Server sequences without a copy here as Library cards, and their place among the index's pages (BRIEF §4.4).</summary>
|
|
public sealed class RemoteCardsTests
|
|
{
|
|
private const string Server = "https://nas.local:8443";
|
|
|
|
private static SyncLink Link(string title, int frames = 100) => new() { Server = Server, RemoteId = Guid.CreateVersion7(), Title = title, FrameCount = frames };
|
|
|
|
private static Sequence Card(string title, DateTime? first, string? camera = null, params string[] tags) =>
|
|
RemoteCards.FromLink(Link(title)) with { FirstCapture = first, CameraModel = camera, Tags = tags };
|
|
|
|
private static Sequence Local(string title, DateTime? first) => new()
|
|
{
|
|
Id = Guid.CreateVersion7(),
|
|
ArchiveId = Guid.CreateVersion7(),
|
|
Title = title,
|
|
Folder = title,
|
|
FirstCapture = first,
|
|
};
|
|
|
|
[Test]
|
|
public void OnlyServerSequencesWithoutALocalCopyBecomeCards()
|
|
{
|
|
var harbour = new Sequence { Id = Guid.CreateVersion7(), ArchiveId = Guid.CreateVersion7(), Folder = "harbour", Title = "Harbour sunset" };
|
|
var sunrise = Link("Sunrise over Superga", 2_880) with { TotalBytes = 60_000_000_000, RemoteStatus = SequenceStatus.ProxiesBuilt, RenderCount = 1 };
|
|
var lake = Link("Lake Como storm");
|
|
SyncEntry[] table =
|
|
[
|
|
new(harbour, Link("Harbour sunset"), SyncStatus.InSync),
|
|
new(harbour with { Id = Guid.CreateVersion7() }, null, SyncStatus.LocalOnly),
|
|
new(null, sunrise, SyncStatus.RemoteOnly),
|
|
new(null, lake, SyncStatus.ProxiesOnly),
|
|
];
|
|
|
|
var cards = RemoteCards.Build(table, null);
|
|
Assert.SequenceEqual([sunrise.RemoteId, lake.RemoteId], cards.Select(c => c.Id));
|
|
var card = cards[0];
|
|
Assert.Equal("Sunrise over Superga", card.DisplayTitle);
|
|
Assert.Equal(2_880, card.FrameCount);
|
|
Assert.Equal(60_000_000_000, card.TotalBytes);
|
|
Assert.Equal(SequenceStatus.ProxiesBuilt, card.Status);
|
|
Assert.Equal(1, card.RenderedCount);
|
|
Assert.Equal(SequenceOrigin.Server, card.Origin);
|
|
Assert.Equal(SyncState.RemoteOnly, card.SyncState);
|
|
Assert.Equal(Guid.Empty, card.ArchiveId, "a remote card belongs to no archive of this PC");
|
|
}
|
|
|
|
[Test]
|
|
public void TheServersListingFillsInTheDetails()
|
|
{
|
|
var link = Link("Sunrise");
|
|
var dto = new SequenceDto(link.RemoteId, "Sunrise over Superga", "Sunrise over Superga", "2026/2026-07-02 Sony ILCE-7M4", "Sony", "ILCE-7M4", null,
|
|
new DateTime(2026, 7, 2, 5, 40, 0), new DateTime(2026, 7, 2, 7, 16, 0), 2_880, 2.0, 60_000_000_000, (int)SequenceStatus.ProxiesBuilt, 1, null,
|
|
["sunrise"], 4, null, 3, 2, 0, null, DateTimeOffset.UtcNow);
|
|
|
|
var card = RemoteCards.Build([new SyncEntry(null, link, SyncStatus.RemoteOnly)], new Dictionary<Guid, SequenceDto> { [dto.Id] = dto }).Single();
|
|
Assert.Equal("Sunrise over Superga", card.DisplayTitle);
|
|
Assert.Equal("ILCE-7M4", card.CameraModel);
|
|
Assert.Equal(new DateTime(2026, 7, 2, 5, 40, 0), card.FirstCapture);
|
|
Assert.SequenceEqual(["sunrise"], card.Tags);
|
|
Assert.Equal(4, card.Rating);
|
|
Assert.Equal(SyncState.RemoteOnly, card.SyncState);
|
|
}
|
|
|
|
[Test]
|
|
public void CardsSortAmongThePagesAndFollowTheFilter()
|
|
{
|
|
var merge = new RemoteMerge();
|
|
var september = Card("Comet", new DateTime(2026, 9, 20), "ILCE-7M4", "stars");
|
|
var july = Card("Sunrise", new DateTime(2026, 7, 2), "ILCE-7M4");
|
|
var undated = Card("Unknown", null);
|
|
var otherYear = Card("Old", new DateTime(2024, 5, 1));
|
|
merge.Reset(new LibraryFilter(), [july, undated, september, otherYear]);
|
|
Assert.Equal(4, merge.Pending);
|
|
|
|
// Newest first: each page takes the cards that sort before its last row, the last page the rest.
|
|
var first = merge.Merge([Local("A", new DateTime(2026, 9, 28)), Local("B", new DateTime(2026, 8, 1))], last: false);
|
|
Assert.SequenceEqual(["A", "Comet", "B"], first.Select(s => s.DisplayTitle));
|
|
var second = merge.Merge([Local("C", new DateTime(2025, 1, 1))], last: false);
|
|
Assert.SequenceEqual(["Sunrise", "C"], second.Select(s => s.DisplayTitle));
|
|
var last = merge.Merge([Local("D", new DateTime(2023, 1, 1))], last: true);
|
|
Assert.SequenceEqual(["Old", "D", "Unknown"], last.Select(s => s.DisplayTitle), "undated cards come last");
|
|
Assert.Equal(0, merge.Pending);
|
|
|
|
merge.Reset(new LibraryFilter { Year = 2026, Text = "sun" }, [july, september, otherYear]);
|
|
Assert.SequenceEqual(["Sunrise"], merge.Merge([], last: true).Select(s => s.DisplayTitle));
|
|
merge.Reset(new LibraryFilter { Tag = "stars" }, [july, september]);
|
|
Assert.SequenceEqual(["Comet"], merge.Merge([], last: true).Select(s => s.DisplayTitle));
|
|
merge.Reset(new LibraryFilter { Origin = OriginFilter.Local }, [july, september]);
|
|
Assert.Equal(0, merge.Pending, "on this PC only: no remote card");
|
|
merge.Reset(new LibraryFilter { Status = StatusFilter.Analysed }, [july]);
|
|
Assert.Equal(0, merge.Pending, "a remote card not analysed does not pass the status filter");
|
|
}
|
|
|
|
[Test]
|
|
public void FiltersCompareLikeTheIndex()
|
|
{
|
|
var byTitle = new LibraryFilter { Sort = SequenceSort.Title };
|
|
Assert.True(byTitle.Compare(Local("aurora", null), Local("Comet", null)) < 0, "titles ignore case");
|
|
var bySize = new LibraryFilter { Sort = SequenceSort.Size };
|
|
Assert.True(bySize.Compare(Local("big", null) with { TotalBytes = 10 }, Local("small", null) with { TotalBytes = 1 }) < 0, "largest first");
|
|
var oldest = new LibraryFilter { Sort = SequenceSort.Oldest };
|
|
Assert.True(oldest.Compare(Local("a", new DateTime(2020, 1, 1)), Local("b", new DateTime(2021, 1, 1))) < 0);
|
|
Assert.True(oldest.Compare(Local("a", null), Local("b", new DateTime(2021, 1, 1))) > 0, "undated last");
|
|
}
|
|
}
|