F4: protocollo e client per manutenzione e impieghi, ADR 0010, stato dei lavori
- Protocollo: riepilogo di manutenzione nei record (blocco 1), RequestDetail, MaintenanceCard, WorkshopRegister, EmploymentReport con depositi, motivi e convenzioni, MaintenanceAlert. - Server: dettagli su richiesta, avvisi dalla manutenzione, registro dopo le convenzioni. - Client: pannelli Officine (cartella di manutenzione, Registro officina, scorta di ricambi, avvisi, mappa di calore) e Impieghi (Registro degli impieghi con convenzioni); schede di treno, industria e città aggiornate; pilota automatico con le nuove schermate. - ADR 0010, PROTOCOL, ARCHITECTURE e STATE aggiornati; 102 test verdi. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0191R7vXgtbAvSV4V8tj8uzL
This commit is contained in:
28 files changed
+1618
-64
No files matched your search
@@ -209,6 +209,53 @@ public static class ServerTests
|
||||
Assert.True(client.Received.OfType<DailyDigest>().Any(), "resoconti giornalieri ricevuti");
|
||||
}
|
||||
|
||||
[Test(Description = "F4 in rete: riepilogo di manutenzione nei record, cartella, registro officina e registro impieghi su richiesta")]
|
||||
public static void MaintenanceDetailsOnRequest() => RunDetails().GetAwaiter().GetResult();
|
||||
|
||||
private static async Task RunDetails()
|
||||
{
|
||||
var scenario = ScenarioHelper.Load("valdoria");
|
||||
await using var server = ServerFixture.Start(scenario.World, tickMs: 50);
|
||||
await using var client = await TestClient.ConnectAsync(server);
|
||||
var w = client.World;
|
||||
await client.WaitFor(() => client.Received.OfType<EntitySnapshot>().FirstOrDefault(), "snapshot");
|
||||
int depot = await client.Ok(new BuildDepotCommand(K(13.2, 5.4), "medium", "Officina di Valdoria"));
|
||||
var loco = await client.Do(new BuyVehicleCommand("loco_steam_1850", new DepotId(depot), 1));
|
||||
var wagon = await client.Do(new BuyVehicleCommand("wagon_box", new DepotId(depot), 1));
|
||||
int train = await client.Ok(new ComposeTrainCommand(new DepotId(depot), loco.Created.Concat(wagon.Created).Select(i => new VehicleId(i)).ToList(), "Treno 1"));
|
||||
await client.WaitUntil(() => w.Trains.ContainsKey(train) && w.Depots.ContainsKey(depot), "treno e officina nella copia locale");
|
||||
Assert.Equal((byte)100, w.Trains[train].Condition);
|
||||
Assert.Equal("inspection", w.Trains[train].NextIntervention);
|
||||
Assert.Equal(4, w.Depots[depot].Stalls);
|
||||
Assert.Equal(TestData.Data.Maintenance.Depots.InitialSpareParts, w.Depots[depot].SpareParts);
|
||||
|
||||
await client.Connection.SendAsync(new RequestDetail { Kind = DetailKind.TrainCard, Target = train });
|
||||
var card = await client.WaitFor(() => w.Cards.GetValueOrDefault(train), "cartella di manutenzione");
|
||||
Assert.Equal(2, card.Vehicles.Count);
|
||||
Assert.Equal(4, card.Vehicles[0].Components.Count);
|
||||
Assert.Equal("engine", card.Vehicles[0].Components[0].Component);
|
||||
Assert.Equal((byte)1, card.Policy);
|
||||
|
||||
await client.Ok(new ScheduleServiceCommand(new TrainId(train), "service"));
|
||||
await client.Connection.SendAsync(new RequestDetail { Kind = DetailKind.Workshop, Target = depot });
|
||||
var register = await client.WaitFor(() => w.Workshops.GetValueOrDefault(depot), "registro officina");
|
||||
Assert.Equal(4, register.Stalls);
|
||||
Assert.Equal(1, register.Jobs.Count);
|
||||
Assert.Equal("service", register.Jobs[0].Intervention);
|
||||
await client.WaitUntil(() => w.Trains[train].Maintenance == TrainMaintenanceStatus.InWorkshop, "treno in officina nel riepilogo");
|
||||
|
||||
await client.Connection.SendAsync(new RequestDetail { Kind = DetailKind.Employment, Target = 0 });
|
||||
var report = await client.WaitFor(() => w.Employment, "registro degli impieghi");
|
||||
var row = report.Rows.FirstOrDefault(r => r.Kind == 1 && r.Industry == depot);
|
||||
Assert.True(row is not null, "l'officina compare nel registro");
|
||||
Assert.Equal(16, row!.JobsStaff);
|
||||
|
||||
// dettagli di entità altrui o inesistenti: nessuna risposta, nessun errore
|
||||
await client.Connection.SendAsync(new RequestDetail { Kind = DetailKind.TrainCard, Target = 999 });
|
||||
await client.Connection.SendAsync(new Ping { Nonce = 5 });
|
||||
await client.WaitFor(() => client.Received.OfType<Pong>().FirstOrDefault(p => p.Nonce == 5), "il server risponde ancora");
|
||||
}
|
||||
|
||||
[Test(Description = "Hello con token errato, dati diversi o protocollo vecchio riceve Reject")]
|
||||
public static void HandshakeRejections() => RunRejections().GetAwaiter().GetResult();
|
||||
|
||||
|
||||
Reference in new issue
Block a user