Commit e8675a12 authored by Mathias Chouet's avatar Mathias Chouet 🍝
Browse files

Fix bug in variated PreBarrage with errors

added spec
parent 3bc4d235
......@@ -6,7 +6,7 @@ import { PbCloison } from "../../src/prebarrage/pb_cloison";
import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params";
import { StructureWeirVillemonte } from "../../src/structure/structure_weir_villemonte";
import { StructureWeirCunge80 } from "../../src/structure/structure_weir_cunge80";
import { MessageCode } from "../../src/index";
import { MessageCode, Session } from "../../src/index";
function createPbCloisonTest(ZDV: number) {
const rectStructPrms = new RectangularStructureParams(
......@@ -317,6 +317,20 @@ describe("Class PreBarrage:", () => {
});
});
describe("variating PreBarrage:", () => {
it("basic variation", () => {
const sess = `{"header":{"source":"jalhyd","format_version":"1.3","created":"2020-09-18T13:42:34.135Z"},"settings":{"precision":1e-7,"maxIterations":100,"displayPrecision":3},"documentation":"","session":[{"uid":"YjJhMX","props":{"calcType":"PreBarrage"},"meta":{"title":"Prébarrages"},"children":[{"uid":"amdscG","props":{"calcType":"PbBassin"},"children":[],"parameters":[{"symbol":"S","mode":"SINGLE","value":13.8},{"symbol":"ZF","mode":"SINGLE","value":95}]},{"uid":"aHVpen","props":{"calcType":"PbCloison","upstreamBasin":"","downstreamBasin":"amdscG"},"children":[{"uid":"aWp4M3","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.3},{"symbol":"L","mode":"SINGLE","value":0.4},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"cGthM2","props":{"calcType":"PbCloison","upstreamBasin":"amdscG","downstreamBasin":""},"children":[{"uid":"amhnaT","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.3},{"symbol":"L","mode":"SINGLE","value":0.4},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]}],"parameters":[{"symbol":"Q","mode":"SINGLE","value":1},{"symbol":"Z1","mode":"CALCUL"},{"symbol":"Z2","mode":"MINMAX","min":98,"max":102,"step":1,"extensionStrategy":0}]}]}`;
Session.getInstance().clear();
Session.getInstance().unserialise(sess);
const pb = Session.getInstance().findNubByUid("YjJhMX") as PreBarrage;
const res = pb.CalcSerie();
expect(res.ok).toBe(false);
expect(res.resultElements.length).toBe(5);
});
});
describe("Basins and Walls results:", () => {
it("basins results", () => {
......
......@@ -241,7 +241,7 @@ export class PreBarrage extends Nub {
// check elevations before calculating
const cgResult = this.checkGeometry();
if (cgResult.resultElement.hasErrorMessages()) {
this._result = cgResult;
this._result.resultElement = cgResult.resultElement;
return this.result;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment