Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions SemiPlot/SemiPlot.Tests.Unit/UI/Export/CsvExportStand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using Microsoft.Extensions.Logging.Abstractions;

using SemiPlot.Core.Data;
using SemiPlot.Core.Export;
using SemiPlot.Core.Trends;
using SemiPlot.UI.Export;
Expand All @@ -25,13 +26,19 @@ internal static class CsvExportStand
public static readonly Pen Argon = new(3, "Argon flow", [], "#FF7F0E", "sccm");
public static readonly Pen Power = new(12, "Bias power", [], "#2CA02C");

public static DateTime ToUtc(DateTime wallClock)
{
return DateTime.SpecifyKind(wallClock - PlusThree.BaseUtcOffset, DateTimeKind.Utc);
}

public static CsvExportViewModel Build(
FakeArchiveRowReader reader,
MessagePanelViewModel messagePanel,
IScheduler uiScheduler,
IReadOnlyList<ExportPenChoice> pens,
DateTime? newestSampleUtc = null,
Func<DateOnly, DateOnly, CancellationToken, Task<Result<IReadOnlyList<DateOnly>>>>? readArchiveDays = null)
Func<DateOnly, DateOnly, CancellationToken, Task<Result<IReadOnlyList<DateOnly>>>>? readArchiveDays = null,
IReadOnlyList<StoredMarker>? markers = null)
{
return new CsvExportViewModel(
reader,
Expand All @@ -45,6 +52,7 @@ public static CsvExportViewModel Build(
StartUtc.AddHours(1),
FirstSampleUtc,
newestSampleUtc,
pens);
pens,
markers ?? []);
}
}
46 changes: 46 additions & 0 deletions SemiPlot/SemiPlot.Tests.Unit/UI/Export/CsvExportViewModelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,52 @@ public async Task APartialFileThatCannotBeDeleted_IsNamedInTheReportedFailure()
.Which.View.Detail.Should().Contain(partialPath);
}

[AvaloniaFact]
public void TheSuggestedName_FollowsTheStartBoxsChoice()
{
var markerWallClock = _startWallClock.AddMinutes(20).AddSeconds(15).AddMilliseconds(400);
var marker = new StoredMarker(
1, CsvExportStand.ToUtc(markerWallClock), "RecipeName.csv", MarkerKind.RecipeStart);
var unlabelled = new StoredMarker(2, CsvExportStand.ToUtc(markerWallClock), null, MarkerKind.User);
using var viewModel = CsvExportStand.Build(
_reader,
_messagePanel,
_scheduler,
[new ExportPenChoice(CsvExportStand.Pressure, true)],
markers: [marker, unlabelled]);

viewModel.SuggestedFileName().Should().Be("semiplot_20261013_080000-20261013_090000.csv");

viewModel.SelectedStartMarker = viewModel.StartMarkers[0];

viewModel.SuggestedFileName().Should().Be("RecipeName_2026-10-13_08-20.csv");

viewModel.SelectedStartMarker = viewModel.StartMarkers[1];

viewModel.SuggestedFileName()
.Should().Be("semiplot_20261013_082015-20261013_090000.csv", "an unlabelled marker names nothing");

viewModel.SelectedStartMarker = viewModel.StartMarkers[0];
viewModel.SelectedStartMarker = viewModel.StartChoices[0];

viewModel.SuggestedFileName()
.Should().Be("semiplot_20261013_082015-20261013_090000.csv", "no marker keeps the range name");

viewModel.SelectedStartMarker = viewModel.StartMarkers[0];
viewModel.Form.StartTimeText = "08:20:16";

viewModel.SuggestedFileName().Should().Be("semiplot_20261013_082016-20261013_090000.csv");

viewModel.Form.StartTimeText = "08:20:15";

viewModel.SuggestedFileName()
.Should().Be("semiplot_20261013_082015-20261013_090000.csv", "a typed time names nothing, the box does");

viewModel.Form.StartTimeText = "08:20";

viewModel.SuggestedFileName().Should().BeNull("an invalid range proposes no name");
}

private CsvExportViewModel BuildNamesakes(bool secondIsTicked)
{
SetSlices(call => call.From == _startWallClock
Expand Down
Loading
Loading