MaBibli 1.0.0
Gestion de bibliothèque personnelle auto-hébergée : catalogue, prêts, scan de code-barres, consultation hors-ligne. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
using MaBibli.Shared.Dtos;
|
||||
|
||||
namespace MaBibli.Tests;
|
||||
|
||||
public class TotauxSeriesTests
|
||||
{
|
||||
[Fact]
|
||||
public void Les_totaux_sont_sommes_recursivement()
|
||||
{
|
||||
var feuilles = new[]
|
||||
{
|
||||
new SerieDto
|
||||
{
|
||||
Id = 2, Titre = "Une", SerieParenteId = 1,
|
||||
Elements = [new ElementSerieDto { Id = 20, Titre = "Possédé", LivreId = 5 }]
|
||||
},
|
||||
new SerieDto
|
||||
{
|
||||
Id = 3, Titre = "Deux", SerieParenteId = 1,
|
||||
Elements = [new ElementSerieDto { Id = 30, Titre = "Manquant" }]
|
||||
},
|
||||
new SerieDto { Id = 1, Titre = "Cycle" },
|
||||
};
|
||||
|
||||
var totaux = TotauxSeries.Calculer(feuilles);
|
||||
|
||||
Assert.Equal((1, 2), totaux[1]);
|
||||
Assert.Equal((1, 1), totaux[2]);
|
||||
Assert.Equal((0, 1), totaux[3]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Une_boucle_dans_les_donnees_ne_fait_pas_boucler_le_calcul()
|
||||
{
|
||||
var series = new[]
|
||||
{
|
||||
new SerieDto { Id = 1, Titre = "Un", SerieParenteId = 2 },
|
||||
new SerieDto
|
||||
{
|
||||
Id = 2, Titre = "Deux", SerieParenteId = 1,
|
||||
Elements = [new ElementSerieDto { Id = 20, Titre = "Tome" }]
|
||||
},
|
||||
};
|
||||
|
||||
var totaux = TotauxSeries.Calculer(series);
|
||||
|
||||
Assert.Equal((0, 1), totaux[1]);
|
||||
Assert.Equal((0, 1), totaux[2]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user