Files
Febe/tests/Febe.Tests/Desktop/AutoExportCompositionTests.cs
T
Alby96andClaude Opus 5.5 9c7f2f1ad5 E5: Dashboard e finestra della cartella dicono il vero sulle copie automatiche
«Riprendi» e «Riprendi tutte» restano attivi mentre lavora una copia
automatica, che cede il passo (risposta 49): li spegne solo un lavoro di
Alberto. «Annulla» di un lavoro automatico dice che i file ripartono da
soli; la risposta a «Interrompi» dice l'ora come il resto («all'1:20»,
«domani alle 0:30»), e «dal» si elide («dall'8 dicembre»). Nella
finestra della cartella «Salva» aspetta il conto dei tipi di adesso, un
conto non riuscito si richiede e il suo errore resta, il fuoco della
tastiera non salta; una nota dice perché «Automatica» è spenta senza
cartelle scrivibili. «Riprendi ora» torna attivo se la richiesta
fallisce. Il conto dei file che aspettano si condivide fra letture e non
si fa per la scheda di un account senza cartella sua; sul telefono i
pulsanti della tabella delle cartelle vanno a capo. Prove nuove: chiusura
che ferma prima il lavoratore, percorso troppo lungo, attesa di due
minuti dall'ultimo file e tetto di un quarto d'ora.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-04 20:07:48 +01:00

61 lines
2.6 KiB
C#

using System.Diagnostics;
using Febe.Core.Export;
using Febe.Tests.Desktop.Support;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace Febe.Tests.Desktop;
/// <summary>
/// The automatic export in the composition (tappa E5, D8): the worker runs only in a normal start (never with a
/// configuration problem; the demo never starts it), runs its start-up round at once, and the stop ends it first.
/// </summary>
[TestClass]
public sealed class AutoExportCompositionTests
{
public TestContext TestContext { get; set; } = null!;
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task TheWorkerRunsInANormalStartAndTheStopEndsIt()
{
var ct = TestContext.CancellationToken;
AutoExportWorker worker;
bool? runningWhenTheInterfaceStops = null;
await using (var bed = await DesktopTestBed.StartAsync())
{
Assert.IsEmpty(bed.App.Problems);
Assert.IsTrue(bed.App.AutoExportStarted);
worker = bed.App.Web.Services.GetRequiredService<AutoExportWorker>();
var seen = worker;
bed.App.Web.Services.GetRequiredService<IHostApplicationLifetime>().ApplicationStopping.Register(() => runningWhenTheInterfaceStops = seen.Running);
var watch = Stopwatch.StartNew();
while ((await worker.StatusAsync(ct)).LastRound is null)
{
Assert.IsLessThan(TimeSpan.FromSeconds(30), watch.Elapsed, "the start-up round did not run");
await Task.Delay(20, ct);
}
var status = await worker.StatusAsync(ct);
Assert.IsTrue(status.Running);
Assert.IsFalse(status.AnyAutomatic, "«Automatica» is off by default");
Assert.AreEqual(status.LastRound + TimeSpan.FromHours(1), status.NextRound);
}
Assert.IsFalse(worker.Running, "the stop ends the worker");
Assert.IsFalse(runningWhenTheInterfaceStops ?? true, "the worker is stopped first, before the interface and the engine");
}
[TestMethod]
[Timeout(60_000, CooperativeCancellation = true)]
public async Task WithAStartupProblemTheWorkerDoesNotRun()
{
await using var bed = await DesktopTestBed.StartAsync(shell: new FakeDesktopShell { RuntimeVersion = null });
Assert.IsNotEmpty(bed.App.Problems);
Assert.IsFalse(bed.App.AutoExportStarted, "the composition does not start it");
var worker = bed.App.Web.Services.GetRequiredService<AutoExportWorker>();
Assert.IsFalse(worker.Running);
Assert.IsNull((await worker.StatusAsync(TestContext.CancellationToken)).LastRound);
}
}