F6: finanza completa con prestiti per rating, conto economico e bancarotta
Completa la finanza della guida 6.3 partendo da un'analisi delle lacune (ADR 0019): prestiti, fido per livello, rate e bancarotta ai giorni di difficulty.json c'erano già; mancavano gli stipendi delle compagnie, un rating spiegabile, il conto economico per voce e gli avvisi. - Prestiti a tasso fisso (base della difficoltà + spread del rating all'accensione), per non innescare la spirale rating -> rata -> utile; rimborso anticipato parziale e totale con messaggi chiari in italiano. - Rating mensile da margine (utile/ricavi sugli ultimi 12 mesi chiusi) e leva (debiti/patrimonio netto); il motore conserva le misure e FinanceOutlook spiega soglie, tassi e cosa serve per salire. - Voci nuove del registro (stazioni e depositi, magazzini, dazi, dividendi incassati) e stipendi del personale presente nei depositi, così il conto economico per voce somma esattamente all'utile operativo del motore. - Mesi e anni chiusi per voce nel salvataggio (versione 7, con migrazione e nell'hash); avvisi di cassa negativa alle scadenze fisse prima del limite della difficoltà, esito dell'ADR 0012 invariato. - Protocollo: DetailKind.Finance e FinanceReport; client: pannello «Finanze» a tutto schermo con conto economico, rating, prestiti e barra della cassa negativa, schermata 18_finanze nel pilota automatico. - Test in Economy/FinanceTests.cs, round-trip del protocollo e quadro via WebSocket; IA e accettazioni F4/F5 invariate. Refs #39. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2e5215c570
commit
9bf64b9286
32 files changed
+2338
-118
No files matched your search
@@ -0,0 +1,546 @@
|
||||
using RailEnterprise.Core.Commands;
|
||||
using RailEnterprise.Core.Common;
|
||||
using RailEnterprise.Core.Data;
|
||||
using RailEnterprise.Core.Economy;
|
||||
using RailEnterprise.Core.Persistence;
|
||||
using RailEnterprise.Core.Rail;
|
||||
using RailEnterprise.Core.Simulation;
|
||||
using RailEnterprise.Core.Simulation.Systems;
|
||||
using RailEnterprise.Server;
|
||||
using RailEnterprise.Tests.Harness;
|
||||
using RailEnterprise.Tests.Rail;
|
||||
|
||||
namespace RailEnterprise.Tests.Economy;
|
||||
|
||||
/// <summary>Finanza completa: prestiti per rating, conto economico per voce, rating spiegato, bancarotta (F6, ADR 0019).</summary>
|
||||
public static class FinanceTests
|
||||
{
|
||||
private static CommandResult Do(World w, GameCommand c)
|
||||
{
|
||||
w.Enqueue(c with { Issuer = w.Player.Id });
|
||||
w.RunTicks(1);
|
||||
return w.DrainResults().Last();
|
||||
}
|
||||
|
||||
private static void SetCash(World w, Company c, Money target)
|
||||
{
|
||||
var delta = target - c.Cash;
|
||||
if (delta.IsPositive) w.Money.Transfer(Account.External, Account.Of(c.Id), delta, LedgerEntry.Other);
|
||||
else if (delta.IsNegative) w.Money.Transfer(Account.Of(c.Id), Account.External, -delta, LedgerEntry.Other);
|
||||
}
|
||||
|
||||
/// <summary>Valdoria con la rete merci, un treno sulla linea e i giorni di servizio indicati.</summary>
|
||||
private static RailFixture ServedValdoria(int days)
|
||||
{
|
||||
var f = RailFixture.Valdoria();
|
||||
var (mine, mill, depot) = f.BuildFreightNetwork();
|
||||
int train = f.Train(depot, "Merci 1", ("loco_steam_1850", 1), ("wagon_hopper", 4));
|
||||
int line = f.Ok(new CreateLineCommand("Linea 1", "#e0a526", new[] { new LineStop(new StationId(mine)), new LineStop(new StationId(mill)) }));
|
||||
f.Ok(new AssignTrainCommand(new TrainId(train), new LineId(line)));
|
||||
f.W.RunDays(days);
|
||||
return f;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ prestiti
|
||||
|
||||
[Test(Description = "Il tasso di un prestito è base della difficoltà + spread del rating, fissato all'accensione")]
|
||||
public static void LoanRateIsBasePlusRatingSpreadAndFixed()
|
||||
{
|
||||
var w = TestWorlds.NoAi(901);
|
||||
var c = w.Player;
|
||||
var fb = w.Data.Balance.Finance;
|
||||
foreach (var rating in new[] { CreditRating.AAA, CreditRating.BBB, CreditRating.CCC })
|
||||
{
|
||||
c.Rating = rating;
|
||||
var r = Do(w, new TakeLoanCommand(Money.FromLire(10_000)));
|
||||
Assert.True(r.Ok, r.Message);
|
||||
var loan = c.Loans[^1];
|
||||
double expected = w.Difficulty.BaseInterestRate + fb.RatingSpreads[rating.ToString()];
|
||||
Assert.Approx(expected, loan.AnnualRate, 1e-12, $"tasso con {rating}");
|
||||
Assert.Approx(expected, FinanceSystem.LoanRate(w, c), 1e-12);
|
||||
Assert.True(r.Message.Contains(FinanceOutlook.Percent(expected)) && r.Message.Contains("rata mensile"), r.Message);
|
||||
}
|
||||
// il rating cambia, i tassi dei prestiti già accesi no
|
||||
var rates = c.Loans.Select(l => l.AnnualRate).ToList();
|
||||
c.Rating = CreditRating.D;
|
||||
w.RunDays(w.Calendar.DaysPerMonth + 1);
|
||||
Assert.SequenceEqual(rates, c.Loans.Select(l => l.AnnualRate).ToList(), "tassi fissi");
|
||||
Assert.True(FinanceSystem.LoanRate(w, w.Player) > rates.Min(), "un nuovo prestito costa secondo il rating nuovo");
|
||||
// tassi crescenti al peggiorare del rating
|
||||
for (int i = 1; i <= (int)CreditRating.D; i++)
|
||||
Assert.True(FinanceSystem.LoanRate(w, (CreditRating)i) >= FinanceSystem.LoanRate(w, (CreditRating)(i - 1)), $"spread di {(CreditRating)i}");
|
||||
}
|
||||
|
||||
[Test(Description = "Il fido è il fido iniziale per il fattore del livello; oltre si rifiuta con un messaggio chiaro e senza effetti")]
|
||||
public static void CreditLimitComesFromTheTierFactor()
|
||||
{
|
||||
var w = TestWorlds.NoAi(902);
|
||||
var c = w.Player;
|
||||
var tiers = w.Data.Tiers.Tiers;
|
||||
Assert.Equal(c.BaseCredit * tiers[0].Unlocks.MaxLoanFactor, FinanceSystem.MaxLoan(w, c));
|
||||
Assert.True(Do(w, new TakeLoanCommand(FinanceSystem.MaxLoan(w, c))).Ok, "tutto il fido");
|
||||
var (loans, debt, cashBefore) = (c.Loans.Count, c.Debt, c.Cash);
|
||||
var refused = Do(w, new TakeLoanCommand(Money.FromLire(1)));
|
||||
Assert.Equal(CommandError.CreditLimit, refused.Error);
|
||||
Assert.True(refused.Message.StartsWith("Fido insufficiente: disponibili ₤ 0"), refused.Message);
|
||||
Assert.Equal(CommandError.InvalidArgument, Do(w, new TakeLoanCommand(Money.Zero)).Error);
|
||||
Assert.Equal((loans, debt), (c.Loans.Count, c.Debt), "i rifiuti non cambiano i prestiti");
|
||||
Assert.True(c.Cash <= cashBefore, "nessun incasso dai rifiuti");
|
||||
|
||||
var higher = tiers.First(t => t.Unlocks.MaxLoanFactor > tiers[0].Unlocks.MaxLoanFactor);
|
||||
c.Tier = higher.Level;
|
||||
Assert.Equal(c.BaseCredit * higher.Unlocks.MaxLoanFactor, FinanceSystem.MaxLoan(w, c));
|
||||
Assert.True(Do(w, new TakeLoanCommand(Money.FromLire(1))).Ok, "il livello alza il fido");
|
||||
|
||||
// in amministrazione controllata niente prestiti nuovi
|
||||
c.Receivership = true;
|
||||
Assert.Equal(CommandError.NotAllowed, Do(w, new TakeLoanCommand(Money.FromLire(1))).Error);
|
||||
Assert.False(FinanceOutlook.Build(w, c.Id).LoansAllowed, "il quadro lo dice");
|
||||
}
|
||||
|
||||
[Test(Description = "Interessi e quota capitale si pagano ogni mese sul registro, alla francese, con il denaro che torna a zero")]
|
||||
public static void MonthlyInterestIsBookedOnTheLedger()
|
||||
{
|
||||
var w = TestWorlds.NoAi(903);
|
||||
var c = w.Player;
|
||||
Assert.True(Do(w, new TakeLoanCommand(Money.FromLire(120_000))).Ok);
|
||||
var loan = c.Loans[0];
|
||||
var interest = Money.FromCentsRounded(loan.Remaining.Cents * loan.AnnualRate / 12);
|
||||
var payment = FinanceSystem.MonthlyPayment(loan.Remaining, loan.AnnualRate, loan.MonthsLeft);
|
||||
var remaining = loan.Remaining;
|
||||
long interestBefore = c.MonthEntries[(int)LedgerEntry.Interest], repaidBefore = c.MonthEntries[(int)LedgerEntry.LoanRepaid];
|
||||
// la rata si paga il primo giorno del mese e finisce nel mese che si chiude
|
||||
w.RunDays(w.Calendar.DaysPerMonth - (int)(w.Clock.Day % w.Calendar.DaysPerMonth));
|
||||
var closed = c.IncomeMonths[^1].Entries;
|
||||
Assert.Equal(-interest.Cents, closed[(int)LedgerEntry.Interest] - interestBefore, "interessi del mese");
|
||||
Assert.Equal(-(payment - interest).Cents, closed[(int)LedgerEntry.LoanRepaid] - repaidBefore, "quota capitale");
|
||||
Assert.Equal(remaining - (payment - interest), loan.Remaining);
|
||||
Assert.Equal(c.Loans[0].MonthsLeft, w.Data.Balance.Finance.LoanTermMonths - 1);
|
||||
Assert.Equal(0L, w.MoneyBalanceSum());
|
||||
// il quadro mostra rata e scadenza coerenti
|
||||
var detail = FinanceOutlook.Build(w, c.Id).LoanList[0];
|
||||
Assert.Equal(FinanceSystem.MonthlyPayment(loan.Remaining, loan.AnnualRate, loan.MonthsLeft), detail.Payment);
|
||||
Assert.Equal(w.Clock.Day / w.Calendar.DaysPerMonth * w.Calendar.DaysPerMonth + (long)loan.MonthsLeft * w.Calendar.DaysPerMonth, detail.MaturityDay);
|
||||
}
|
||||
|
||||
[Test(Description = "Rimborso anticipato parziale (rata più bassa, stessa durata) e totale; cassa insufficiente e prestito inesistente rifiutati")]
|
||||
public static void EarlyRepaymentPartialAndTotal()
|
||||
{
|
||||
var w = TestWorlds.NoAi(904);
|
||||
var c = w.Player;
|
||||
Assert.True(Do(w, new TakeLoanCommand(Money.FromLire(100_000))).Ok);
|
||||
var loan = c.Loans[0];
|
||||
var payment = FinanceSystem.MonthlyPayment(loan.Remaining, loan.AnnualRate, loan.MonthsLeft);
|
||||
int months = loan.MonthsLeft;
|
||||
|
||||
var partial = Do(w, new RepayLoanCommand(loan.Id, Money.FromLire(40_000)));
|
||||
Assert.True(partial.Ok, partial.Message);
|
||||
Assert.Equal(Money.FromLire(60_000), loan.Remaining);
|
||||
Assert.Equal(months, loan.MonthsLeft, "la durata non cambia");
|
||||
var lower = FinanceSystem.MonthlyPayment(loan.Remaining, loan.AnnualRate, loan.MonthsLeft);
|
||||
Assert.True(lower < payment, "la rata scende");
|
||||
Assert.True(partial.Message.Contains($"nuova rata mensile {lower}"), partial.Message);
|
||||
|
||||
// cassa insufficiente: rifiuto con gli importi, nulla cambia
|
||||
var cash = c.Cash;
|
||||
SetCash(w, c, Money.FromLire(1_000));
|
||||
var owed = loan.Remaining;
|
||||
var poor = Do(w, new RepayLoanCommand(loan.Id, loan.Remaining));
|
||||
Assert.Equal(CommandError.InsufficientFunds, poor.Error);
|
||||
Assert.True(poor.Message.Contains("Cassa insufficiente") && poor.Message.Contains(loan.Remaining.ToString()), poor.Message);
|
||||
Assert.Equal(owed, loan.Remaining, "il rifiuto non rimborsa nulla");
|
||||
SetCash(w, c, cash);
|
||||
|
||||
Assert.Equal(CommandError.NotFound, Do(w, new RepayLoanCommand(new LoanId(999), Money.FromLire(1))).Error);
|
||||
var total = Do(w, new RepayLoanCommand(loan.Id, Money.FromLire(1_000_000)));
|
||||
Assert.True(total.Ok && total.Message.Contains("prestito estinto"), total.Message);
|
||||
Assert.Equal(0, c.Loans.Count);
|
||||
Assert.Equal(Money.Zero, c.Debt);
|
||||
Assert.Equal(0L, w.MoneyBalanceSum());
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ rating
|
||||
|
||||
/// <summary>Mese chiuso con i ricavi e i costi indicati (centesimi), per costruire la finestra del rating.</summary>
|
||||
private static IncomeRecord Month(int year, int month, long revenue, long cost)
|
||||
{
|
||||
var e = new long[Company.EntryCount];
|
||||
e[(int)LedgerEntry.FreightRevenue] = revenue;
|
||||
e[(int)LedgerEntry.RunningCosts] = -cost;
|
||||
return new IncomeRecord { Year = year, Month = month, Entries = e };
|
||||
}
|
||||
|
||||
[Test(Description = "Il rating è funzione documentata di utile/ricavi (12 mesi) e debiti/patrimonio; le misure restano per spiegarlo")]
|
||||
public static void RatingComesFromMarginAndLeverage()
|
||||
{
|
||||
var w = TestWorlds.NoAi(905);
|
||||
var c = w.Player;
|
||||
var fb = w.Data.Balance.Finance;
|
||||
c.IncomeMonths.Clear();
|
||||
for (int m = 1; m <= 12; m++) c.IncomeMonths.Add(Month(1850, m, 100_000_00, 80_000_00)); // margine 20 %
|
||||
FinanceSystem.UpdateRating(w, c);
|
||||
Assert.Approx(0.2, c.RatingMargin, 1e-12, "margine");
|
||||
Assert.Equal(12, c.RatingMonths);
|
||||
long debt = c.Debt.Cents + Math.Max(0, -c.Cash.Cents);
|
||||
Assert.Approx(debt == 0 ? 0 : (double)debt / c.NetWorth.Cents, c.RatingLeverage, 1e-12, "leva");
|
||||
double score = fb.ProfitMarginWeight * Math.Clamp(0.5 + 0.2, 0, 1) + fb.LeverageWeight * (1 / (1 + c.RatingLeverage));
|
||||
Assert.Approx(score, c.RatingScore, 1e-12, "punteggio");
|
||||
Assert.Equal(FinanceSystem.RatingOf(w, score), c.Rating);
|
||||
var noDebt = c.Rating;
|
||||
|
||||
// più debito (stesso patrimonio): leva più alta, rating non migliore
|
||||
Assert.True(Do(w, new TakeLoanCommand(FinanceSystem.MaxLoan(w, c))).Ok);
|
||||
FinanceSystem.UpdateBookValues(w);
|
||||
FinanceSystem.UpdateRating(w, c);
|
||||
Assert.Approx((double)c.Debt.Cents / c.NetWorth.Cents, c.RatingLeverage, 1e-12, "debiti/patrimonio");
|
||||
Assert.True(c.Rating >= noDebt, $"con debito {c.Rating}, senza {noDebt}");
|
||||
|
||||
// margine negativo: rating non migliore; margine alto: non peggiore
|
||||
var leveraged = c.Rating;
|
||||
for (int i = 0; i < 12; i++) c.IncomeMonths[i] = Month(1850, i + 1, 100_000_00, 150_000_00);
|
||||
FinanceSystem.UpdateRating(w, c);
|
||||
Assert.Approx(-0.5, c.RatingMargin, 1e-12);
|
||||
Assert.True(c.Rating >= leveraged, "in perdita il rating non sale");
|
||||
for (int i = 0; i < 12; i++) c.IncomeMonths[i] = Month(1850, i + 1, 100_000_00, 10_000_00);
|
||||
FinanceSystem.UpdateRating(w, c);
|
||||
Assert.True(c.Rating <= leveraged, "con il 90 % di margine il rating non scende");
|
||||
|
||||
// patrimonio negativo con debiti: leva infinita, componente nulla
|
||||
SetCash(w, c, Money.FromLire(-10_000_000));
|
||||
FinanceSystem.UpdateRating(w, c);
|
||||
Assert.True(double.IsPositiveInfinity(c.RatingLeverage), "leva infinita");
|
||||
Assert.Approx(fb.ProfitMarginWeight * 1.0, c.RatingScore, 1e-12);
|
||||
c.Bankrupt = true;
|
||||
FinanceSystem.UpdateRating(w, c);
|
||||
Assert.Equal(CreditRating.D, c.Rating, "in bancarotta è D");
|
||||
}
|
||||
|
||||
[Test(Description = "La spiegazione del rating dice cosa serve per salire: il margine o la leva indicati portano al gradino sopra")]
|
||||
public static void RatingExplanationReachesTheNextNotch()
|
||||
{
|
||||
var w = TestWorlds.NoAi(906);
|
||||
var c = w.Player;
|
||||
var fb = w.Data.Balance.Finance;
|
||||
Assert.True(Do(w, new TakeLoanCommand(Money.FromLire(200_000))).Ok);
|
||||
c.IncomeMonths.Clear();
|
||||
for (int m = 1; m <= 12; m++) c.IncomeMonths.Add(Month(1850, m, 100_000_00, 95_000_00)); // margine 5 %
|
||||
FinanceSystem.UpdateBookValues(w);
|
||||
FinanceSystem.UpdateRating(w, c);
|
||||
var e = FinanceOutlook.Explain(w, c);
|
||||
Assert.False(e.Initial, "misure dell'ultimo calcolo");
|
||||
Assert.Equal(c.Rating, e.Rating);
|
||||
Assert.Approx(c.RatingScore, e.Score, 1e-12);
|
||||
Assert.Equal(fb.RatingByScore.Length, e.Thresholds.Count);
|
||||
Assert.True(e.Next is not null, "c'è un gradino sopra");
|
||||
Assert.Approx(fb.RatingByScore[(int)e.Next!.Value], e.NextThreshold, 1e-12);
|
||||
Assert.True(e.Score < e.NextThreshold && e.Score >= (c.Rating == CreditRating.D ? 0 : fb.RatingByScore[(int)c.Rating]), "punteggio tra le due soglie");
|
||||
if (e.MarginReachable)
|
||||
Assert.Equal(e.Next.Value, FinanceSystem.RatingOf(w, FinanceSystem.Score(w, e.MarginNeeded + 1e-9, c.RatingLeverage)), "con il margine indicato si sale");
|
||||
if (e.LeverageReachable)
|
||||
{
|
||||
Assert.Equal(e.Next.Value, FinanceSystem.RatingOf(w, FinanceSystem.Score(w, c.RatingMargin, e.LeverageMax - 1e-9)), "con la leva indicata si sale");
|
||||
// rimborsando il debito indicato la leva scende sotto il massimo (il patrimonio non cambia)
|
||||
var live = FinanceSystem.Measures(c);
|
||||
Assert.True((double)(live.Debt - e.DebtToRepay.Cents) / live.Equity <= e.LeverageMax + 1e-9, "debito da rimborsare");
|
||||
}
|
||||
Assert.True(e.MarginReachable || e.LeverageReachable, "almeno una via per salire");
|
||||
|
||||
// la prima volta il rating è quello dei dati e le misure sono di oggi
|
||||
var fresh = TestWorlds.NoAi(907);
|
||||
var first = FinanceOutlook.Explain(fresh, fresh.Player);
|
||||
Assert.True(first.Initial);
|
||||
Assert.Equal(fb.StartingRating, first.Rating);
|
||||
}
|
||||
|
||||
[Test(Description = "Il rating si aggiorna ogni mese sulla finestra degli ultimi 12 mesi chiusi")]
|
||||
public static void RatingUsesTheLastTwelveClosedMonths()
|
||||
{
|
||||
var f = ServedValdoria(0);
|
||||
var w = f.W;
|
||||
var c = w.Player;
|
||||
int months = w.Data.Balance.Finance.IncomeMonths;
|
||||
w.RunDays((months + 2) * w.Calendar.DaysPerMonth);
|
||||
Assert.Equal(months, c.IncomeMonths.Count, "finestra piena e non oltre");
|
||||
Assert.Equal(months, c.RatingMonths);
|
||||
// i mesi sono consecutivi e finiscono col mese appena chiuso
|
||||
var last = w.Calendar.DateOfDay(w.Clock.Day / w.Calendar.DaysPerMonth * w.Calendar.DaysPerMonth - 1);
|
||||
Assert.Equal((last.Year, last.Month), (c.IncomeMonths[^1].Year, c.IncomeMonths[^1].Month));
|
||||
// le misure conservate sono quelle della finestra (il rating si ricalcola solo a inizio mese)
|
||||
long revenue = c.IncomeMonths.Sum(m => Company.Revenue(m.Entries));
|
||||
long profit = c.IncomeMonths.Sum(m => Company.OperatingProfit(m.Entries));
|
||||
Assert.Approx(revenue > 0 ? (double)profit / revenue : 0, c.RatingMargin, 1e-12);
|
||||
Assert.True(revenue > 0, "la linea incassa");
|
||||
// l'anello dell'utile della borsa e i mesi del conto economico hanno la stessa fonte
|
||||
long ring = c.AnnualProfit;
|
||||
Assert.Equal(c.IncomeMonths.Skip(months - 12).Sum(m => Company.OperatingProfit(m.Entries)), ring);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ conto economico
|
||||
|
||||
[Test(Description = "Il conto economico per voce somma esattamente all'utile operativo del motore in ogni colonna")]
|
||||
public static void IncomeStatementSumsToOperatingProfit()
|
||||
{
|
||||
var f = ServedValdoria(0);
|
||||
var w = f.W;
|
||||
var c = w.Player;
|
||||
Assert.True(Do(w, new TakeLoanCommand(Money.FromLire(50_000))).Ok);
|
||||
w.RunDays(w.Calendar.DaysPerYear + 3 * w.Calendar.DaysPerMonth);
|
||||
var report = FinanceOutlook.Build(w, c.Id);
|
||||
Assert.Equal(Company.EntryCount, report.Lines.Count);
|
||||
Assert.Equal(Company.EntryCount, report.Lines.Select(l => l.Entry).Distinct().Count(), "ogni voce una volta");
|
||||
Assert.True(report.Columns.Count >= 3, "mese, mesi chiusi, anno");
|
||||
Assert.Equal(IncomeColumnKind.CurrentMonth, report.Columns[0].Kind);
|
||||
Assert.True(report.Columns.Any(x => x.Kind == IncomeColumnKind.Year), "un anno chiuso");
|
||||
foreach (var col in report.Columns)
|
||||
{
|
||||
long operating = report.Lines.Where(l => l.Section != IncomeSection.Capital).Sum(l => col.Entries[(int)l.Entry]);
|
||||
long all = col.Entries.Sum();
|
||||
Assert.Equal(col.Profit.Cents, operating, $"utile {col.Kind} {col.Month}/{col.Year}");
|
||||
Assert.Equal(Company.OperatingProfit(col.Entries), col.Profit.Cents);
|
||||
Assert.Equal(col.CashFlow.Cents, all, "flusso di cassa");
|
||||
}
|
||||
Assert.Equal(Company.OperatingProfit(c.MonthEntries), report.Columns[0].Profit.Cents, "mese in corso dal registro");
|
||||
var year = report.Columns.First(x => x.Kind == IncomeColumnKind.Year);
|
||||
Assert.SequenceEqual(c.LastYearEntries, year.Entries, "anno chiuso = registro dell'anno precedente");
|
||||
// la scalata mostra lo stesso utile dell'ultimo anno chiuso
|
||||
Assert.Equal(ClimbOutlook.Income(w, c).Profit, year.Profit);
|
||||
// voci vive: tariffe, esercizio dei treni, stazioni e depositi, interessi
|
||||
Assert.True(year.Entries[(int)LedgerEntry.FreightRevenue] > 0, "noli");
|
||||
Assert.True(year.Entries[(int)LedgerEntry.RunningCosts] < 0, "esercizio dei treni");
|
||||
Assert.True(year.Entries[(int)LedgerEntry.StationUpkeep] < 0, "stazioni e depositi");
|
||||
Assert.True(year.Entries[(int)LedgerEntry.Interest] < 0, "interessi");
|
||||
Assert.Equal(0L, w.MoneyBalanceSum());
|
||||
}
|
||||
|
||||
[Test(Description = "Il personale presente nei depositi riceve gli stipendi alle paghe delle industrie, sulla voce «Stipendi»")]
|
||||
public static void DepotStaffIsPaidWages()
|
||||
{
|
||||
var f = RailFixture.Valdoria();
|
||||
var net = f.BuildMaintenanceNetwork(partsLine: false, trainsPerLine: 0);
|
||||
var w = f.W;
|
||||
var depot = w.Network.Depots[net.Officina];
|
||||
w.RunDays(w.Calendar.DaysPerMonth + 1);
|
||||
Assert.True(depot.StaffPresent > 0 && depot.WorkersPresent > 0, $"personale presente: {depot.StaffPresent} tecnici, {depot.WorkersPresent} operai");
|
||||
long before = w.Player.YearEntries[(int)LedgerEntry.Wages];
|
||||
w.RunDays(1);
|
||||
var ib = w.Data.Balance.Industry;
|
||||
double expected = 0;
|
||||
foreach (var d in w.Network.Depots)
|
||||
{
|
||||
if (d.Owner == w.Player.Id && w.Network.IsAlive(d))
|
||||
expected += (d.WorkersPresent * ib.WagePerWorkerPerMonth + d.StaffPresent * ib.WagePerStaffPerMonth) / w.Calendar.DaysPerMonth;
|
||||
}
|
||||
Assert.Equal(-Money.FromCentsRounded(expected).Cents, w.Player.YearEntries[(int)LedgerEntry.Wages] - before, "stipendi del giorno");
|
||||
Assert.True(Company.OperatingProfit(w.Player.YearEntries) < Company.OperatingProfit(w.Player.YearEntries) - w.Player.YearEntries[(int)LedgerEntry.Wages],
|
||||
"gli stipendi riducono l'utile operativo");
|
||||
Assert.Equal(0L, w.MoneyBalanceSum());
|
||||
}
|
||||
|
||||
[Test(Description = "Dazi degli hub e giacenze dei magazzini sulle loro voci, con lo stesso netto per la cassa")]
|
||||
public static void DutiesAndStorageHaveTheirOwnEntries()
|
||||
{
|
||||
var f = RailFixture.Valdoria();
|
||||
var w = f.W;
|
||||
w.Player.Tier = w.Data.Tiers.Tiers.First(t => t.Unlocks.Trading).Level;
|
||||
int port = f.Ok(new BuildStationCommand(RailFixture.K(14.5, 6.3), 2, "Porto di Levante"));
|
||||
var hub = w.Hubs[0];
|
||||
int coal = w.Data.Goods.First(g => g.Id == "coal").Index;
|
||||
double price = hub.SellPrice(w.Market.GlobalPrice[coal]);
|
||||
var cash = w.Player.Cash;
|
||||
long trading = w.Player.YearEntries[(int)LedgerEntry.Trading], duties = w.Player.YearEntries[(int)LedgerEntry.Duties];
|
||||
var r = f.Do(new BuyGoodsCommand(new StationId(port), "coal", 60, Money.FromCentsRounded(price + 1)));
|
||||
Assert.True(r.Ok, r.Message);
|
||||
long paid = (cash - w.Player.Cash).Cents;
|
||||
long duty = -(w.Player.YearEntries[(int)LedgerEntry.Duties] - duties);
|
||||
Assert.Approx(60 * price * hub.Duty / (1 + hub.Duty), duty, 1, "dazio d'importazione");
|
||||
Assert.Equal(-(paid - duty), w.Player.YearEntries[(int)LedgerEntry.Trading] - trading, "il resto è commercio");
|
||||
|
||||
// vendita all'hub: incasso a Pg e dazio a parte, netto = prezzo d'esportazione
|
||||
cash = w.Player.Cash;
|
||||
duties = w.Player.YearEntries[(int)LedgerEntry.Duties];
|
||||
double sell = hub.BuyPrice(w.Market.GlobalPrice[coal]);
|
||||
var s = f.Do(new SellGoodsCommand(new StationId(port), "coal", 20, Money.Zero));
|
||||
Assert.True(s.Ok, s.Message);
|
||||
Assert.Approx(20 * sell, (w.Player.Cash - cash).Cents, 1, "incasso netto");
|
||||
Assert.True(w.Player.YearEntries[(int)LedgerEntry.Duties] < duties, "dazio d'esportazione");
|
||||
|
||||
// giacenza mensile sulla voce «Magazzini»
|
||||
long storage = w.Player.YearEntries[(int)LedgerEntry.Storage];
|
||||
f.W.RunDays(w.Calendar.DaysPerMonth + 1);
|
||||
Assert.True(w.Player.YearEntries[(int)LedgerEntry.Storage] < storage || w.Player.LastYearEntries[(int)LedgerEntry.Storage] < 0, "giacenza addebitata");
|
||||
Assert.Equal(0L, w.MoneyBalanceSum());
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ bancarotta
|
||||
|
||||
[Test(Slow = true, Description = "Cassa negativa: avviso subito e alle scadenze fisse, bancarotta esattamente ai giorni di difficulty.json per ogni preset")]
|
||||
public static void BankruptcyFollowsTheDifficultyDays()
|
||||
{
|
||||
var fb = TestData.Data.Balance.Finance;
|
||||
foreach (var preset in TestData.Data.Difficulty.Presets)
|
||||
{
|
||||
var w = TestWorlds.NoAi(910, preset.Id);
|
||||
var c = w.Player;
|
||||
Assert.Equal(preset.BankruptcyDays, w.Difficulty.BankruptcyDays, preset.Id);
|
||||
SetCash(w, c, Money.FromLire(-1_000_000));
|
||||
w.Events.Drain();
|
||||
var warnings = new List<(int Day, GameEvent Event)>();
|
||||
int days = 0;
|
||||
while (!c.Bankrupt && days < preset.BankruptcyDays + 5)
|
||||
{
|
||||
w.RunDays(1);
|
||||
days++;
|
||||
foreach (var e in w.Events.Drain())
|
||||
{
|
||||
if (e.Kind == EventKind.Finance && e.Company == c.Id) warnings.Add((c.NegativeCashDays, e));
|
||||
}
|
||||
}
|
||||
Assert.True(c.Bankrupt, $"{preset.Id}: bancarotta");
|
||||
Assert.Equal(preset.BankruptcyDays, c.NegativeCashDays, $"{preset.Id}: giorni di cassa negativa");
|
||||
Assert.Equal(preset.BankruptcyDays, days, $"{preset.Id}: giorni trascorsi");
|
||||
Assert.True(warnings[0].Day == 1 && warnings[0].Event.Text.Contains($"bancarotta arriva tra {preset.BankruptcyDays - 1} giorni"), $"{preset.Id}: {warnings[0].Event.Text}");
|
||||
foreach (int left in fb.BankruptcyWarningDaysLeft.Where(l => l < preset.BankruptcyDays - 1))
|
||||
{
|
||||
Assert.True(warnings.Any(x => x.Day == preset.BankruptcyDays - left && x.Event.Text.Contains($"bancarotta tra {(left == 1 ? "1 giorno" : $"{left} giorni")}")),
|
||||
$"{preset.Id}: avviso a {left} giorni");
|
||||
}
|
||||
var last = warnings[^1].Event;
|
||||
Assert.True(last.Severity == EventSeverity.Critical && last.Text.Contains("dichiarata la bancarotta"), last.Text);
|
||||
// l'esito segue la regola della difficoltà (ADR 0012): senza IA che la rilevino la partita finisce
|
||||
w.RunDays(1);
|
||||
Assert.True(w.GameOver is not null, $"{preset.Id}: fine partita");
|
||||
Assert.Equal(0L, w.MoneyBalanceSum());
|
||||
}
|
||||
}
|
||||
|
||||
[Test(Description = "Se la cassa torna positiva il conto alla rovescia si azzera con un avviso")]
|
||||
public static void PositiveCashResetsTheCountdown()
|
||||
{
|
||||
var w = TestWorlds.NoAi(911);
|
||||
var c = w.Player;
|
||||
var cash = c.Cash;
|
||||
SetCash(w, c, Money.FromLire(-1_000));
|
||||
w.RunDays(5);
|
||||
Assert.Equal(5, c.NegativeCashDays);
|
||||
var report = FinanceOutlook.Build(w, c.Id);
|
||||
Assert.Equal(5, report.NegativeCashDays);
|
||||
Assert.Equal(w.Difficulty.BankruptcyDays, report.BankruptcyDays);
|
||||
Assert.Equal(Money.FromLire(1_000), report.Overdraft);
|
||||
w.Events.Drain();
|
||||
SetCash(w, c, cash);
|
||||
w.RunDays(1);
|
||||
Assert.Equal(0, c.NegativeCashDays);
|
||||
Assert.True(w.Events.Drain().Any(e => e.Company == c.Id && e.Kind == EventKind.Finance && e.Text.Contains("torna positiva")), "avviso di rientro");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ salvataggi e determinismo
|
||||
|
||||
[Test(Description = "Mesi e anni chiusi e misure del rating nel salvataggio (versione 7) e nell'hash; la versione 6 si migra")]
|
||||
public static void FinanceStateSurvivesSavesAndMigrates()
|
||||
{
|
||||
var f = ServedValdoria(0);
|
||||
var w = f.W;
|
||||
var c = w.Player;
|
||||
Assert.True(Do(w, new TakeLoanCommand(Money.FromLire(30_000))).Ok);
|
||||
w.RunDays(w.Calendar.DaysPerYear + 2 * w.Calendar.DaysPerMonth);
|
||||
Assert.True(c.IncomeMonths.Count > 0 && c.IncomeYears.Count > 0 && c.RatingMonths > 0, "stato da salvare");
|
||||
|
||||
var loaded = SaveFile.Load(TestData.Data, SaveFile.Save(w, "test"));
|
||||
var lc = loaded.Player;
|
||||
Assert.Equal(c.IncomeMonths.Count, lc.IncomeMonths.Count);
|
||||
for (int i = 0; i < c.IncomeMonths.Count; i++)
|
||||
{
|
||||
Assert.Equal((c.IncomeMonths[i].Year, c.IncomeMonths[i].Month), (lc.IncomeMonths[i].Year, lc.IncomeMonths[i].Month));
|
||||
Assert.SequenceEqual(c.IncomeMonths[i].Entries, lc.IncomeMonths[i].Entries);
|
||||
}
|
||||
Assert.SequenceEqual(c.IncomeYears[0].Entries, lc.IncomeYears[0].Entries);
|
||||
Assert.Equal(c.RatingScore, lc.RatingScore);
|
||||
Assert.Equal(c.RatingMargin, lc.RatingMargin);
|
||||
Assert.Equal(StateHasher.Compute(w), StateHasher.Compute(loaded));
|
||||
|
||||
// i mesi entrano nell'hash
|
||||
ulong hash = StateHasher.Compute(w);
|
||||
c.IncomeMonths[0].Entries[(int)LedgerEntry.Wages]--;
|
||||
Assert.NotEqual(hash, StateHasher.Compute(w), "un mese chiuso cambia l'hash");
|
||||
c.IncomeMonths[0].Entries[(int)LedgerEntry.Wages]++;
|
||||
|
||||
// stesso futuro dopo il caricamento
|
||||
w.RunDays(40);
|
||||
loaded.RunDays(40);
|
||||
Assert.Equal(StateHasher.Compute(w), StateHasher.Compute(loaded), "stesso futuro");
|
||||
|
||||
// versione 6: nessun mese conservato, l'anno chiuso dal registro, il rating resta
|
||||
var v6 = new SaveWriter(1 << 20);
|
||||
WorldSerializer.Write(w, v6, 6);
|
||||
var migrated = WorldSerializer.Read(TestData.Data, new SaveReader(v6.WrittenSpan.ToArray()));
|
||||
var mc = migrated.Player;
|
||||
Assert.Equal(0, mc.IncomeMonths.Count);
|
||||
Assert.Equal(0, mc.RatingMonths);
|
||||
Assert.Equal(c.Rating, mc.Rating);
|
||||
Assert.Equal(1, mc.IncomeYears.Count);
|
||||
Assert.SequenceEqual(c.LastYearEntries, mc.IncomeYears[0].Entries);
|
||||
Assert.True(FinanceOutlook.Explain(migrated, mc).Initial, "spiegazione con le misure di oggi fino al primo calcolo");
|
||||
migrated.RunDays(w.Calendar.DaysPerMonth);
|
||||
Assert.Equal(1, mc.IncomeMonths.Count);
|
||||
Assert.Equal(1, mc.RatingMonths);
|
||||
Assert.Equal(0L, migrated.MoneyBalanceSum());
|
||||
}
|
||||
|
||||
[Test(Description = "Stesso seme e stessi comandi finanziari danno lo stesso hash; denaro e merci restano in equilibrio")]
|
||||
public static void FinanceIsDeterministicAndKeepsInvariants()
|
||||
{
|
||||
ulong Run()
|
||||
{
|
||||
var f = ServedValdoria(0);
|
||||
var w = f.W;
|
||||
Assert.True(Do(w, new TakeLoanCommand(Money.FromLire(40_000))).Ok);
|
||||
w.RunDays(200);
|
||||
Assert.True(Do(w, new RepayLoanCommand(w.Player.Loans[0].Id, Money.FromLire(10_000))).Ok);
|
||||
w.RunDays(200);
|
||||
Assert.Equal(0L, w.MoneyBalanceSum(), "denaro");
|
||||
for (int g = 0; g < w.Data.GoodCount; g++) Assert.Equal(w.Goods.ExpectedStock(g), w.TotalStock(g), $"merce {w.Data.Goods[g].Id}");
|
||||
return StateHasher.Compute(w);
|
||||
}
|
||||
Assert.Equal(Run(), Run());
|
||||
}
|
||||
|
||||
[Test(Description = "Il quadro delle finanze si proietta nel protocollo con le stesse somme del motore")]
|
||||
public static void ProjectionMatchesTheEngine()
|
||||
{
|
||||
var f = ServedValdoria(2 * 30);
|
||||
var w = f.W;
|
||||
Assert.True(Do(w, new TakeLoanCommand(Money.FromLire(20_000))).Ok);
|
||||
ulong hash = StateHasher.Compute(w);
|
||||
var report = FinanceOutlook.Build(w, w.Player.Id);
|
||||
var message = Projection.Finance(w, w.Player.Id);
|
||||
Assert.Equal(hash, StateHasher.Compute(w), "il quadro non cambia il mondo");
|
||||
Assert.Equal(report.Columns.Count, message.Columns.Count);
|
||||
for (int i = 0; i < report.Columns.Count; i++)
|
||||
{
|
||||
Assert.Equal(report.Columns[i].Profit, message.Columns[i].Profit);
|
||||
foreach (var line in message.Lines) Assert.Equal(report.Columns[i].Entries[line.Kind], message.Columns[i].Value(line.Kind).Cents);
|
||||
}
|
||||
Assert.Equal(w.Player.Rating.ToString(), message.Rating);
|
||||
Assert.Equal(1, message.LoanList.Count);
|
||||
Assert.Equal(report.LoanList[0].Payment, message.LoanList[0].Payment);
|
||||
Assert.Equal(w.Difficulty.BankruptcyDays, message.BankruptcyDays);
|
||||
}
|
||||
|
||||
[Test(Description = "I dividendi tra compagnie escono come dividendi pagati (fuori dall'utile) ed entrano come dividendi incassati (nell'utile)")]
|
||||
public static void DividendsReceivedCountInOperatingProfit()
|
||||
{
|
||||
var w = TestWorlds.Small(912);
|
||||
var payer = w.Companies.First(c => !c.Id.Equals(w.Player.Id));
|
||||
var me = w.Player;
|
||||
long profitBefore = Company.OperatingProfit(me.YearEntries), payerProfit = Company.OperatingProfit(payer.YearEntries);
|
||||
var amount = Money.FromLire(2_500);
|
||||
w.Money.Transfer(Account.Of(payer.Id), Account.Of(me.Id), amount, LedgerEntry.Dividends, LedgerEntry.DividendsReceived);
|
||||
Assert.Equal(amount.Cents, me.YearEntries[(int)LedgerEntry.DividendsReceived], "incassati");
|
||||
Assert.Equal(-amount.Cents, payer.YearEntries[(int)LedgerEntry.Dividends], "pagati");
|
||||
Assert.Equal(profitBefore + amount.Cents, Company.OperatingProfit(me.YearEntries), "nell'utile di chi incassa");
|
||||
Assert.Equal(payerProfit, Company.OperatingProfit(payer.YearEntries), "fuori dall'utile di chi paga");
|
||||
Assert.Equal(IncomeSection.Revenue, LedgerEntries.Section(LedgerEntry.DividendsReceived));
|
||||
Assert.Equal(IncomeSection.Capital, LedgerEntries.Section(LedgerEntry.Dividends));
|
||||
Assert.Equal(0L, w.MoneyBalanceSum());
|
||||
}
|
||||
}
|
||||
@@ -188,6 +188,29 @@ public static class ProtocolTests
|
||||
MaxLoan = new Money(100_000_000), LoanAvailable = new Money(88_000_000), NewLoanRate = 0.061f, LoansAllowed = false,
|
||||
History = [new NetWorthPointInfo { Day = 0, Value = new Money(25_000_000) }, new NetWorthPointInfo { Day = 2600, Value = new Money(39_144_993) }],
|
||||
};
|
||||
yield return new FinanceReport
|
||||
{
|
||||
Day = 2610, Company = 0, Cash = new Money(-120_000), NetWorth = new Money(39_000_000), Loans = new Money(12_000_000), Overdraft = new Money(120_000),
|
||||
Lines = [new FinanceLineInfo { Kind = 0, Section = FinanceLineInfo.SectionRevenue }, new FinanceLineInfo { Kind = 9, Section = FinanceLineInfo.SectionCost },
|
||||
new FinanceLineInfo { Kind = 2, Section = FinanceLineInfo.SectionCapital }],
|
||||
Columns =
|
||||
[
|
||||
new IncomeColumnInfo { Kind = IncomeColumnInfo.CurrentMonth, Year = 1872, Month = 3, Values = [new AmountInfo { Kind = 0, Value = new Money(150_000) }],
|
||||
Profit = new Money(150_000), CashFlow = new Money(150_000) },
|
||||
new IncomeColumnInfo { Kind = IncomeColumnInfo.ClosedYear, Year = 1871, Values = [new AmountInfo { Kind = 9, Value = new Money(-66_000) }, new AmountInfo { Kind = 2, Value = new Money(-1_000) }],
|
||||
Profit = new Money(-66_000), CashFlow = new Money(-67_000) },
|
||||
],
|
||||
Rating = "BBB", RatingInitial = false, RatingMonths = 12, Margin = 0.28f, Leverage = 0.31f, LeverageUnbounded = false,
|
||||
MarginWeight = 0.6f, LeverageWeight = 0.4f, MarginComponent = 0.78f, LeverageComponent = 0.76f, Score = 0.772f,
|
||||
Thresholds = [new RatingThresholdInfo { Rating = "AAA", MinScore = 0.85f, LoanRate = 0.055f }, new RatingThresholdInfo { Rating = "C", MinScore = 0.05f, LoanRate = 0.17f }],
|
||||
NextRating = "A", NextThreshold = 0.65f, MarginNeeded = 0.31f, MarginReachable = true, LeverageMax = 0.12f, LeverageReachable = false,
|
||||
DebtToRepay = new Money(7_000_000),
|
||||
LoanList = [new FinanceLoanInfo { Loan = 4, Principal = new Money(15_000_000), Remaining = new Money(12_000_000), AnnualRate = 0.075f, MonthsLeft = 97,
|
||||
Payment = new Money(171_234), NextInterest = new Money(75_000), MaturityDay = 5520 }],
|
||||
MaxLoan = new Money(60_000_000), LoanAvailable = new Money(48_000_000), NewLoanRate = 0.075f, BaseRate = 0.05f, Spread = 0.025f,
|
||||
LoanTermMonths = 120, LoanStep = new Money(5_000_000), LoansAllowed = false,
|
||||
NegativeCashDays = 12, BankruptcyDays = 90, Bankrupt = false, Receivership = true,
|
||||
};
|
||||
yield return new CommandResultMessage { Seq = 99, Type = (ushort)CommandType.BuildTrack, Error = 10, Message = "Pendenza eccessiva", Created = [1, 2, 3], Tick = 4000 };
|
||||
yield return new Notification { Event = SampleEvent() };
|
||||
yield return new Newspaper { Day = 30, Title = "La Cronaca di Valdoria", Articles = [("Nuova linea", "Inaugurata la linea per il valico."), ("Prezzi", "Il carbone sale.")] };
|
||||
|
||||
@@ -351,6 +351,52 @@ public static class ServerTests
|
||||
Assert.Equal(Money.FromLire(5_000), after.Loans);
|
||||
}
|
||||
|
||||
[Test(Description = "Il quadro delle finanze arriva su richiesta e dopo un prestito riporta il prestito nuovo (ADR 0019)")]
|
||||
public static void FinanceReportOnRequest() => RunFinance().GetAwaiter().GetResult();
|
||||
|
||||
private static async Task RunFinance()
|
||||
{
|
||||
var scenario = ScenarioHelper.Load("valdoria");
|
||||
int limit = scenario.World.Difficulty.BankruptcyDays;
|
||||
await using var server = ServerFixture.Start(scenario.World);
|
||||
await using var client = await TestClient.ConnectAsync(server);
|
||||
var w = client.World;
|
||||
var data = TestData.Data;
|
||||
await client.WaitUntil(() => w.LastDigest is { Day: >= 2 }, "due giorni di partita");
|
||||
|
||||
// il server non manda il quadro da solo: si aspetta la risposta a questa richiesta
|
||||
Assert.True(w.Finance is null, "nessun quadro prima della richiesta");
|
||||
await client.Connection.SendAsync(new RequestDetail { Kind = DetailKind.Finance, Target = 0 });
|
||||
var report = await client.WaitFor(() => w.Finance, "quadro delle finanze");
|
||||
Assert.True(report.Day >= 2, $"giorno {report.Day}");
|
||||
Assert.Equal(w.Summary!.CompanyId, report.Company);
|
||||
Assert.Equal(global::RailEnterprise.Core.Economy.Company.EntryCount, report.Lines.Count);
|
||||
Assert.Equal(IncomeColumnInfo.CurrentMonth, report.Columns[0].Kind);
|
||||
Assert.True(report.Columns.Any(c => c.Kind == IncomeColumnInfo.CurrentYear), "colonna dell'anno in corso");
|
||||
foreach (var col in report.Columns)
|
||||
{
|
||||
long operating = report.Lines.Where(l => l.Section != FinanceLineInfo.SectionCapital).Sum(l => col.Value(l.Kind).Cents);
|
||||
Assert.Equal(col.Profit.Cents, operating, $"le voci d'esercizio sommano all'utile ({col.Kind} {col.Month}/{col.Year})");
|
||||
}
|
||||
Assert.Equal(data.Balance.Finance.RatingByScore.Length, report.Thresholds.Count);
|
||||
Assert.True(report.RatingInitial, "prima del primo mese il rating è quello iniziale");
|
||||
Assert.Equal(limit, report.BankruptcyDays);
|
||||
Assert.Equal(0, report.LoanList.Count);
|
||||
|
||||
// dopo un prestito una nuova richiesta riporta il prestito: si aspetta la risposta nuova, non quella vecchia
|
||||
var result = await client.Do(new TakeLoanCommand(Money.FromLire(5_000)));
|
||||
Assert.True(result.Error == 0, result.Message);
|
||||
var stale = w.Finance;
|
||||
await client.Connection.SendAsync(new RequestDetail { Kind = DetailKind.Finance, Target = 0 });
|
||||
var after = await client.WaitFor(() => ReferenceEquals(w.Finance, stale) ? null : w.Finance, "quadro aggiornato");
|
||||
Assert.Equal(1, after.LoanList.Count);
|
||||
var loan = after.LoanList[0];
|
||||
Assert.Equal(Money.FromLire(5_000), loan.Principal);
|
||||
Assert.Approx(after.NewLoanRate, loan.AnnualRate, 1e-6, "tasso fissato all'accensione");
|
||||
Assert.True(loan.Payment.Cents > 0 && loan.MaturityDay > after.Day, "rata e scadenza");
|
||||
Assert.Equal(Money.FromLire(5_000), after.Loans);
|
||||
}
|
||||
|
||||
[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