Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
51 lines
1.4 KiB
C#
51 lines
1.4 KiB
C#
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]);
|
|
}
|
|
}
|