public void TestComputeScore() { Notebook nb = new Notebook(); // UE 1 Unit u = new Unit(); nb.AddUnit(u); Module m1 = new Module(); Module m2 = new Module(); m1.Coef = 2; m2.Coef = 4; m1.Name = "Maths"; m2.Name = "ProgCSharp"; Exam e1 = new Exam(); Exam e2 = new Exam(); Exam e3 = new Exam(); // Ajout des exams pour le premier module e1.Module = m1; e1.Coef = 1; e1.Score = 15; nb.Exams.Add(e1); // Ajout pour le 2eme module e2.Module = m2; e2.Coef = 2; e2.Score = 10; nb.Exams.Add(e2); e3.Module = m2; e3.Coef = 2; e3.Score = 20; u.AddModule(m1); u.AddModule(m2); nb.Exams.Add(e3); // UE 2 Unit u2 = new Unit(); nb.AddUnit(u2); Module m3 = new Module(); Module m4 = new Module(); m3.Coef = 1; m4.Coef = 1; m3.Name = "Anglais"; m4.Name = "ExprCom"; Exam e4 = new Exam(); Exam e5 = new Exam(); Exam e6 = new Exam(); // Ajout des exams pour le premier module e4.Module = m3; e4.Coef = 4; e4.Score = 14; nb.Exams.Add(e4); // Ajout pour le 2eme module e5.Module = m4; e5.Coef = 1; e5.Score = 15; nb.Exams.Add(e5); e6.Module = m4; e6.Coef = 1; e6.Score = 15; nb.Exams.Add(e6); u2.AddModule(m3); u2.AddModule(m4); // Calcule du notebook AvgScore[] listresult = nb.ComputeScore(); AvgScore expected1 = new AvgScore(15, u); AvgScore result1 = listresult[0]; AvgScore expected2 = new AvgScore((float)15, u2); AvgScore result2 = listresult[1]; Assert.Equal(expected1.Average, result1.Average); Assert.Equal(expected2.Average, result2.Average); }