From 81539e622081c657e1670cadc93722da630f3156 Mon Sep 17 00:00:00 2001
From: David Dorchies <david.dorchies@irstea.fr>
Date: Fri, 23 Mar 2018 12:24:17 +0100
Subject: [PATCH] =?UTF-8?q?Ajout=20de=20tests=20sur=20les=20r=C3=A9sultats?=
 =?UTF-8?q?=20compl=C3=A9mentaires=20de=20ParallelStructure?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 spec/structure/parallel_structure.spec.ts | 11 ++++++++++-
 spec/structure/structure_test.ts          | 10 ++++++----
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/spec/structure/parallel_structure.spec.ts b/spec/structure/parallel_structure.spec.ts
index edacedee..1f2d7d9b 100644
--- a/spec/structure/parallel_structure.spec.ts
+++ b/spec/structure/parallel_structure.spec.ts
@@ -102,6 +102,16 @@ describe("Class ParallelStructure: ", () => {
     for (let i = 0; i < ps2.structures.length; i++) {
         const st: Structure = ps2.structures[i];
         describe(`this.structures[${i}]: ${StructureType[iStTypes[i]]} Structure${LoiDebit[iLoiDebits[i]]}: `, () => {
+            // Tests sur les résultats complémentaires
+            it(`Calc(Q).extraResults[${i}.Q] should return ${ps2.structures[i].Calc("Q").vCalc}`, () => {
+                expect(
+                    ps2.Calc("Q").extraResults[`${i}.Q`]
+                ).toBe(
+                    ps2.structures[i].Calc("Q").vCalc
+                );
+            });
+
+            // Tests de calcul des paramètres des ouvrages
             for (const prm of st.prms) {
                 if (
                     prm.calculability === ParamCalculability.DICHO &&
@@ -121,7 +131,6 @@ describe("Class ParallelStructure: ", () => {
                         prm.symbol === "ZDV"
                     ) {
                         // Les lois CEM88D et CUNGE80 ne font pas intervenir ZDV dans le calcul d'un orifice noyé
-                        // TODO Il faudrait générer une erreur pour dire que le résultat est indéfini
                         it(`Calc(${prm.symbol}) should return an error`, () => {
                             expect(
                                 ps2.Calc(i + "." + prm.symbol).code
diff --git a/spec/structure/structure_test.ts b/spec/structure/structure_test.ts
index 8fefd6ab..6ff1af5f 100644
--- a/spec/structure/structure_test.ts
+++ b/spec/structure/structure_test.ts
@@ -6,8 +6,9 @@
  */
 // import { describe, expect, it, xdescribe, xit } from "../mock_jasmine";
 
+import { MessageCode } from "../../src";
 import { ParamCalculability } from "../../src/param/param-definition";
-import { Structure, StructureParams, StructureFlowRegime, StructureFlowMode } from "../../src/structure/structure";
+import { Structure, StructureFlowMode, StructureFlowRegime, StructureParams } from "../../src/structure/structure";
 import { Result } from "../../src/util/result";
 import { checkResult } from "../test_func";
 
@@ -77,9 +78,10 @@ export function testStructure(
                 const res: Result = st.Calc(prm.symbol);
                 if (bNotZDV) {
                     // Les lois CEM88D et CUNGE80 ne font pas intervenir ZDV dans le calcul d'un orifice noyé
-                    // TODO Il faudrait générer une erreur pour dire que le résultat est indéfini
-                    xit(`Calc(${prm.symbol}) should return undefined`, () => {
-                        checkResult(res, undefined);
+                    it(`Calc(${prm.symbol}) should return an error`, () => {
+                        expect(
+                            st.Calc(prm.symbol).code
+                        ).toBe(MessageCode.ERROR_STRUCTURE_ZDV_PAS_CALCULABLE);
                     });
                 } else {
                     // On ne teste pas le calcul de l'ouverture sur les seuils
-- 
GitLab