An error occurred while loading the file. Please try again.
-
Pierre-Antoine Rouby authored475c9fb2
// tslint:disable-next-line:no-reference
/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
import { Result } from "../../src/base";
import { Structure, StructureFlowMode, StructureFlowRegime, StructureParams} from "../../src/structure/structure";
import { equalEpsilon } from "../nubtest";
function check(val1: Result, val2: number) {
expect(equalEpsilon(val1.vCalc, val2)).toBe(true);
}
class StructureTest extends Structure {
constructor(prms: StructureParams, dbg: boolean = false) {
super(prms, dbg);
}
/**
* Test of getFlowMode
*/
public testGetFlowMode() {
return this.getFlowMode();
}
/**
* Test of getFlowRegime
*/
public testGetFlowRegime() {
return this.getFlowRegime();
}
public Equation(sVarCalc: string): Result {
let v: number;
switch (sVarCalc) {
case "Q":
v = this.prms.h1.v - this.prms.h2.v;
break;
default:
throw new Error("StructureTest.Equation() : invalid parameter name " + sVarCalc);
}
return new Result(v);
}
}
const structTestPrm: StructureParams = new StructureParams(1, 30, 15);
const structTest: StructureTest = new StructureTest(structTestPrm, false);
describe("Class Structure: ", () => {
describe("getFlowMode()", () => {
it("Flow Mode should be WEIR", () => {
expect(structTest.testGetFlowMode()).toBe(StructureFlowMode.WEIR);
});
it("Flow Mode should be ORIFICE", () => {
structTest.prms.W.v = 10;
expect(structTest.testGetFlowMode()).toBe(StructureFlowMode.ORIFICE);
structTest.prms.W.v = Infinity;
});
});
describe("getFlowRegime()", () => {
it("Flow Regime should be FREE", () => {
expect(structTest.testGetFlowRegime()).toBe(StructureFlowRegime.FREE);
});
it("Flow Regime should be SUBMERGED (WEIR)", () => {
structTest.prms.h2.v = 21;
expect(structTest.testGetFlowRegime()).toBe(StructureFlowRegime.SUBMERGED);
});
it("Flow Regime should be PARTIAL (ORIFICE)", () => {
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
structTest.prms.h2.v = 21;
structTest.prms.W.v = 15;
expect(structTest.testGetFlowRegime()).toBe(StructureFlowRegime.PARTIAL);
});
it("Flow Regime should be SUBMERGED (ORIFICE)", () => {
structTest.prms.h2.v = 25;
structTest.prms.W.v = 15;
expect(structTest.testGetFlowRegime()).toBe(StructureFlowRegime.SUBMERGED);
});
structTest.prms.h2.v = 15;
structTest.prms.W.v = Infinity;
});
describe("Calc()", () => {
const flagsNull = {Mode: StructureFlowMode.NULL, Regime: StructureFlowRegime.NULL};
it("h1=h2 => Q=0", () => {
structTest.prms.h2.v = structTest.prms.h1.v;
check(structTest.Calc("Q"), 0);
expect(structTest.Calc("Q").extraVar).toEqual(flagsNull);
structTest.prms.h2.v = 15;
});
it("W=0 => Q=0", () => {
structTest.prms.W.v = 0;
check(structTest.Calc("Q"), 0);
expect(structTest.Calc("Q").extraVar).toEqual(flagsNull);
structTest.prms.W.v = Infinity;
});
it("Q=0 => h1=h2", () => {
structTest.prms.Q.v = 0;
check(structTest.Calc("h1"), structTest.prms.h2.v);
expect(structTest.Calc("h1").extraVar).toEqual(flagsNull);
structTest.prms.Q.v = 1;
});
it("Q=0 => W=0", () => {
structTest.prms.Q.v = 0;
check(structTest.Calc("W"), 0);
expect(structTest.Calc("W").extraVar).toEqual(flagsNull);
structTest.prms.Q.v = 1;
});
// TODO Test inversion de débit
});
});