Files
Chronos/tests/Titano.App.Tests/Import/CardPoolTests.cs
T
Claude a0e814885c feat(app): Import and Archive manager screens with capture scenes and resources
Import (cards and folders): the card pool with remembered profiles and the
nickname field for new cards, the form (destination, scan, sessions, names
with live preview and tokens, duplicates, after-import choices), the plan
panel with editable session titles, Show plan, the archive import job or
the folder/server run with progress, the verification result and the
after-import actions (dry run, delete, format through the Windows dialog,
eject, open in Library), card-insertion toasts, automatic import into the
archive and resume after re-insertion. Deep analysis after import is queued
with ProcessingJobs at background priority.

Archive manager: archive picker, tree with availability, figure tiles and
charts, mass operations on the selected set, scan/rebuild (dialog)/verify/
duplicates/orphans/adopt/maintenance as jobs, and the maintenance view with
index health, recent runs and the duplicate and orphan reports with safe
fixes.

--capture renders import-<state> and archive-<view> from a simulated card
and sample reports; en and it resources for both screens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
2026-10-02 22:20:10 +00:00

66 lines
2.9 KiB
C#

using System.Globalization;
using Titano.App.Import;
using Titano.Core.Localization;
using Titano.Core.Model;
using Titano.Testing;
namespace Titano.App.Tests.Import;
public sealed class CardPoolTests
{
private static readonly CardDevice CardA = new(@"F:\", "EOS_DIGITAL", 0x3F2A9C11, 128_000_000_000, 31_800_000_000, true, true);
private static readonly CardDevice GoPro = new(@"E:\", "GOPRO", 0x11112222, 64_000_000_000, 52_600_000_000, true, true);
private static readonly CardDevice Usb = new(@"G:\", "BACKUP", 0x99990000, 2_000_000_000_000, 1_800_000_000_000, true, false);
public CardPoolTests() => Loc.SetCulture(CultureInfo.GetCultureInfo("en"));
private static MediaCard Known(CardDevice device, string nickname, DateTimeOffset seen) => new()
{
Id = Guid.CreateVersion7(),
Identity = device.Identity,
VolumeSerial = device.SerialNumber,
Label = device.Label,
Capacity = device.TotalBytes,
Nickname = nickname,
CameraMake = "Canon",
CameraModel = "Canon EOS R5",
CameraSerial = "0431",
LastSeen = seen,
};
[Test]
public void InsertedVolumesComeFirstThenRememberedCardsThenTheFolder()
{
var away = new CardDevice(@"H:\", "NIKON", 0x55556666, 64_000_000_000, 0, true, true);
var cards = new[] { Known(CardA, "EOS R5 · card A", DateTimeOffset.UtcNow), Known(away, "Z 8 card", DateTimeOffset.UtcNow.AddDays(-3)) };
var pool = CardPool.Build([Usb, CardA, GoPro], cards, @"D:\Shoots\2026");
Assert.SequenceEqual(new[] { GoPro.Identity, CardA.Identity, Usb.Identity, away.Identity, @"D:\Shoots\2026" }, pool.Select(s => s.Key));
Assert.Equal(SourceKind.Card, pool[0].Kind);
Assert.False(pool[0].IsKnown);
Assert.Equal("GOPRO", pool[0].Title);
Assert.Equal("New card", pool[0].StateText);
Assert.Equal("EOS R5 · card A", pool[1].Title);
Assert.Equal("Known card", pool[1].StateText);
Assert.Equal("128 GB · 96.2 GB used", pool[1].Subtitle);
Assert.Equal("128 GB · serial 3F2A-9C11 · Canon EOS R5 #0431", pool[1].IdentityText);
Assert.Equal(SourceKind.Drive, pool[2].Kind);
Assert.Equal("no DCIM · 1.8 TB free", pool[2].Subtitle);
Assert.False(pool[3].IsInserted);
Assert.Null(pool[3].Root);
Assert.Equal("Canon EOS R5 · not inserted", pool[3].Subtitle);
Assert.Equal(SourceKind.Folder, pool[4].Kind);
Assert.Equal(@"D:\Shoots\2026", pool[4].Root);
}
[Test]
public void AKnownCardWithoutDcimIsStillACard()
{
var pool = CardPool.Build([Usb], [Known(Usb, "Backup card", DateTimeOffset.UtcNow)], null);
Assert.Equal(SourceKind.Card, pool.Single().Kind);
Assert.Equal("3F2A-9C11", ImportSource.SerialText(0x3F2A9C11));
Assert.Equal("3F2A9C11-EOS_DIGITAL-128000000000", CardA.Identity);
Assert.Equal("EOS_DIGITAL", CardA.ToVolume().Label);
}
}