Files
Chronos/tests/Titano.App.Tests/Library/LibraryCsvTests.cs
T
Claude 7f94c9a839 test(app): Library logic tests, capture scenes and smoke tests
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
2026-10-03 16:44:10 +00:00

46 lines
1.7 KiB
C#

using Titano.App.Library;
using Titano.Core.Model;
using Titano.Testing;
namespace Titano.App.Tests.Library;
/// <summary>"Export list as CSV" (BRIEF §12.2): RFC 4180 rows that spreadsheets read as data, never as formulas.</summary>
public sealed class LibraryCsvTests
{
[Test]
public void RowsAreQuotedInvariantAndSafe()
{
var harbour = new Sequence
{
Id = Guid.CreateVersion7(),
ArchiveId = Guid.CreateVersion7(),
Title = "Harbour, \"golden\" hour",
Folder = "2026/2026-09-28 Canon EOS R5",
CameraMake = "Canon",
CameraModel = "Canon EOS R5",
FirstCapture = new DateTime(2026, 9, 28, 18, 2, 11),
LastCapture = new DateTime(2026, 9, 28, 20, 2, 9),
FrameCount = 3_600,
TotalBytes = 96_200_000_000,
Tags = ["sunset", "harbour"],
};
var formula = new Sequence
{
Id = Guid.CreateVersion7(),
ArchiveId = Guid.Empty,
Folder = string.Empty,
Title = "=HYPERLINK(\"x\")",
Origin = SequenceOrigin.Server,
SyncState = SyncState.RemoteOnly,
};
var lines = LibraryCsv.Write([harbour, formula]).Split("\r\n");
Assert.Equal("title,first_capture,last_capture,camera_make,camera_model,frames,bytes,folder,tags,origin", lines[0]);
Assert.Equal("\"Harbour, \"\"golden\"\" hour\",2026-09-28 18:02:11,2026-09-28 20:02:09,Canon,Canon EOS R5,3600,96200000000,"
+ "2026/2026-09-28 Canon EOS R5,sunset;harbour,local", lines[1]);
Assert.Equal("\"'=HYPERLINK(\"\"x\"\")\",,,,,0,0,,,server", lines[2]);
Assert.Equal(string.Empty, lines[3], "every row ends with CRLF");
}
}