structure.spec.ts 3.16 KB
Newer Older
1
import { StructureFlowMode, StructureFlowRegime, StructureJetType } from "../../src/structure/structure";
2
import { checkResult } from "../test_func";
Dorchies David's avatar
Dorchies David committed
3
import { CreateStructTest, StructureTest } from "./structure_test";
4

5
describe("Class Structure: ", () => {
Dorchies David's avatar
Dorchies David committed
6
7
8
9
    let structTest: StructureTest;
    beforeAll( () => {
        structTest = CreateStructTest();
    });
10
11
    describe("getFlowMode()", () => {
        it("Flow Mode should be WEIR", () => {
12
            expect(structTest.testGetFlowMode()).toBe(StructureFlowMode.WEIR);
13
14
        });
        it("Flow Mode should be ORIFICE", () => {
15
16
17
            structTest.prms.W.v = 10;
            expect(structTest.testGetFlowMode()).toBe(StructureFlowMode.ORIFICE);
            structTest.prms.W.v = Infinity;
18
        });
19
20
    });

21
22
    describe("getFlowRegime()", () => {
        it("Flow Regime should be FREE", () => {
23
            expect(structTest.testGetFlowRegime()).toBe(StructureFlowRegime.FREE);
24
25
        });
        it("Flow Regime should be SUBMERGED (WEIR)", () => {
26
            structTest.prms.Z2.v = 21;
27
28
            expect(structTest.testGetFlowRegime()).toBe(StructureFlowRegime.SUBMERGED);
        });
29
        it("Flow Regime should be PARTIAL (ORIFICE)", () => {
30
            structTest.prms.Z2.v = 21;
31
32
33
            structTest.prms.W.v = 15;
            expect(structTest.testGetFlowRegime()).toBe(StructureFlowRegime.PARTIAL);
        });
34
        it("Flow Regime should be SUBMERGED (ORIFICE)", () => {
Dorchies David's avatar
Dorchies David committed
35
            structTest.prms.Z2.v = 26;
36
37
            structTest.prms.W.v = 15;
            expect(structTest.testGetFlowRegime()).toBe(StructureFlowRegime.SUBMERGED);
Dorchies David's avatar
Dorchies David committed
38
39
            structTest.prms.Z2.v = 15;
            structTest.prms.W.v = Infinity;
40
41
        });
    });
42

43
    describe("Calc()", () => {
Dorchies David's avatar
Dorchies David committed
44
45
        const flagsNull = {
            ENUM_StructureFlowMode: StructureFlowMode.NULL,
46
47
            ENUM_StructureFlowRegime: StructureFlowRegime.NULL,
            ENUM_StructureJetType: StructureJetType.SO
Dorchies David's avatar
Dorchies David committed
48
        };
49
        it("Z1=Z2 => Q=0", () => {
50
            structTest.prms.Z2.v = structTest.prms.Z1.v;
51
            checkResult(structTest.Calc("Q"), 0);
52
            expect(structTest.Calc("Q").extraResults).toEqual(flagsNull);
53
            structTest.prms.Z2.v = 15;
54
        });
55
        it("W=0 => Q=0", () => {
56
            structTest.prms.W.v = 0;
57
58
            const r = structTest.Calc("Q");
            checkResult(r, 0);
59
            expect(r.extraResults).toEqual(flagsNull);
60
61
            structTest.prms.W.v = Infinity;
        });
62
        it("Q=0 => Z1=Z2", () => {
Dorchies David's avatar
Dorchies David committed
63
64
65
            structTest.prms.Q.singleValue = 0;
            structTest.calculatedParam = structTest.prms.Q;
            checkResult(structTest.CalcSerie(), structTest.prms.h2.v);
66
            // expect(structTest.Calc("Z1").values).toEqual(flagsNull);
Dorchies David's avatar
Dorchies David committed
67
            structTest.prms.Q.singleValue = 1;
68
        });
69
        it("Q=0 => W=0", () => {
70
            structTest.prms.Q.v = 0;
71
            structTest.prms.W.v = 1; // Sinon, W = Infinity => Structure = Seuil => Throw Error
72
            checkResult(structTest.Calc("W"), 0);
73
            expect(structTest.Calc("W").extraResults).toEqual(flagsNull);
74
75
76
77
            structTest.prms.Q.v = 1;
        });
        // TODO Test inversion de débit
    });
78
});