Commit 1323023a authored by Mathias Chouet's avatar Mathias Chouet 🍝
Browse files

oops inverted names of 2 spec files

parent 625a9483
import { Session } from "../src/session";
import { CreateStructure } from "../src/structure/factory_structure";
import { ParallelStructure } from "../src/structure/parallel_structure";
import { ParallelStructureParams } from "../src/structure/parallel_structure_params";
import { LoiDebit } from "../src/structure/structure_props";
import { MessageCode } from "../src/util/message";
import { YAXB } from "../src/yaxb";
import { YAXBParams } from "../src/yaxb_params";
describe("Class YAXB: ", () => {
describe("Calc: ", () => {
it("Y should be 10", () => {
const nub = new YAXB(new YAXBParams(666, 2, 3, 4));
nub.calculatedParam = nub.prms.Y;
nub.CalcSerie();
expect(nub.result.vCalc).toBe(10);
import { ConduiteDistrib } from "../src/cond_distri";
import { ConduiteDistribParams } from "../src/cond_distri_params";
import { checkResult } from "./test_func";
describe("Class ConduiteDistrib: ", () => {
// beforeEach(() => {
// });
// beforeAll(() => {
// });
describe("Calc(): ", () => {
it("Q should be 9.393", () => {
const prms = new ConduiteDistribParams(undefined, // débit Q
1.2, // diamètre D
0.6, // perte de charge J
100, // Longueur de la conduite Lg
1e-6, // Viscosité dynamique Nu
);
const nub = new ConduiteDistrib(prms);
checkResult(nub.Calc("Q", 0), 9.393);
});
});
it("A should be 2", () => {
const nub = new YAXB(new YAXBParams(10, 666, 3, 4));
nub.calculatedParam = nub.prms.A;
nub.CalcSerie();
expect(nub.result.vCalc).toBe(2);
describe("Calc(): ", () => {
it("Q should be 152.992", () => {
const prms = new ConduiteDistribParams(undefined, // débit Q
2, // diamètre D
0.7, // perte de charge J
10, // Longueur de la conduite Lg
1e-6, // Viscosité dynamique Nu
);
const nub = new ConduiteDistrib(prms);
nub.prms.D.v = 2;
nub.prms.J.v = 0.7;
nub.prms.Lg.v = 10;
nub.prms.Nu.v = 1e-6;
checkResult(nub.Calc("Q", 0), 152.992);
});
});
it("X should be 3", () => {
const nub = new YAXB(new YAXBParams(10, 2, 666, 4));
nub.calculatedParam = nub.prms.X;
nub.CalcSerie();
expect(nub.result.vCalc).toBe(3);
});
describe("Calc(): ", () => {
it("D should be 2.12847", () => {
const prms = new ConduiteDistribParams(3, // débit Q
undefined, // diamètre D
0.7, // perte de charge J
10, // Longueur de la conduite Lg
1e-6, // Viscosité dynamique Nu
);
it("B should be 4", () => {
const nub = new YAXB(new YAXBParams(10, 2, 3, 666));
nub.calculatedParam = nub.prms.B;
nub.CalcSerie();
expect(nub.result.vCalc).toBe(4);
});
const nub = new ConduiteDistrib(prms);
it("calc A with X = 0 should trigger error", () => {
const nub = new YAXB(new YAXBParams(10, 666, 0, 4));
nub.calculatedParam = nub.prms.A;
nub.CalcSerie();
expect(nub.result.ok).toBe(false);
expect(nub.result.resultElement.log.messages.length).toBe(1);
expect(nub.result.resultElement.log.messages[0].code).toBe(MessageCode.ERROR_DIVISION_BY_ZERO);
const r = nub.Calc("D", 0);
checkResult(r, 2.12847);
});
});
it("calc X with A = 0 should trigger error", () => {
const nub = new YAXB(new YAXBParams(10, 0, 666, 4));
nub.calculatedParam = nub.prms.X;
nub.CalcSerie();
expect(nub.result.ok).toBe(false);
expect(nub.result.resultElement.log.messages.length).toBe(1);
expect(nub.result.resultElement.log.messages[0].code).toBe(MessageCode.ERROR_DIVISION_BY_ZERO);
});
describe("Calc(): ", () => {
it("J should be 0.00814", () => {
const prms = new ConduiteDistribParams(3, // débit Q
1.2, // diamètre D
undefined, // perte de charge J
10, // Longueur de la conduite Lg
1e-6, // Viscosité dynamique Nu
);
const nub = new ConduiteDistrib(prms);
checkResult(nub.Calc("J", 0), 0.00814);
});
});
describe("Link: ", () => {
describe("Calc(): ", () => {
it("Lg should be 737.021", () => {
const prms = new ConduiteDistribParams(3, // débit Q
1.2, // diamètre D
0.6, // perte de charge J
undefined, // Longueur de la conduite Lg
1e-6, // Viscosité dynamique Nu
);
const nub = new ConduiteDistrib(prms);
it("all parameters must be linkable to Y,A,X,B in both ways", () => {
const yaxb = new YAXB(new YAXBParams(10, 2, 3, 4));
const lo = new ParallelStructure(new ParallelStructureParams(1.2, 102, 101));
lo.addChild(CreateStructure(LoiDebit.GateCem88d, lo));
checkResult(nub.Calc("Lg", 0), 737.021);
});
});
Session.getInstance().clear();
Session.getInstance().registerNubs([ yaxb, lo ]);
describe("Calc(): ", () => {
it("Nu should be 0.00295", () => {
const prms = new ConduiteDistribParams(3, // débit Q
1.2, // diamètre D
0.6, // perte de charge J
100, // Longueur de la conduite Lg
undefined, // Viscosité dynamique Nu
);
// each YAXB param should be linkable to all ParallelStructures params
expect(Session.getInstance().getLinkableValues(yaxb.prms.Y).length).toBe(7);
expect(Session.getInstance().getLinkableValues(yaxb.prms.A).length).toBe(7);
expect(Session.getInstance().getLinkableValues(yaxb.prms.X).length).toBe(7);
expect(Session.getInstance().getLinkableValues(yaxb.prms.B).length).toBe(7);
const nub = new ConduiteDistrib(prms);
// each ParallelStructures param should be linkable to all YAXB params
for (const p of lo.parameterIterator) {
expect(Session.getInstance().getLinkableValues(p).length).toBe(4);
}
checkResult(nub.Calc("Nu", 0), 0.00295);
});
});
});
import { ConduiteDistrib } from "../src/cond_distri";
import { ConduiteDistribParams } from "../src/cond_distri_params";
import { checkResult } from "./test_func";
describe("Class ConduiteDistrib: ", () => {
// beforeEach(() => {
// });
// beforeAll(() => {
// });
describe("Calc(): ", () => {
it("Q should be 9.393", () => {
const prms = new ConduiteDistribParams(undefined, // débit Q
1.2, // diamètre D
0.6, // perte de charge J
100, // Longueur de la conduite Lg
1e-6, // Viscosité dynamique Nu
);
const nub = new ConduiteDistrib(prms);
checkResult(nub.Calc("Q", 0), 9.393);
import { Session } from "../src/session";
import { CreateStructure } from "../src/structure/factory_structure";
import { ParallelStructure } from "../src/structure/parallel_structure";
import { ParallelStructureParams } from "../src/structure/parallel_structure_params";
import { LoiDebit } from "../src/structure/structure_props";
import { MessageCode } from "../src/util/message";
import { YAXB } from "../src/yaxb";
import { YAXBParams } from "../src/yaxb_params";
describe("Class YAXB: ", () => {
describe("Calc: ", () => {
it("Y should be 10", () => {
const nub = new YAXB(new YAXBParams(666, 2, 3, 4));
nub.calculatedParam = nub.prms.Y;
nub.CalcSerie();
expect(nub.result.vCalc).toBe(10);
});
});
describe("Calc(): ", () => {
it("Q should be 152.992", () => {
const prms = new ConduiteDistribParams(undefined, // débit Q
2, // diamètre D
0.7, // perte de charge J
10, // Longueur de la conduite Lg
1e-6, // Viscosité dynamique Nu
);
const nub = new ConduiteDistrib(prms);
nub.prms.D.v = 2;
nub.prms.J.v = 0.7;
nub.prms.Lg.v = 10;
nub.prms.Nu.v = 1e-6;
checkResult(nub.Calc("Q", 0), 152.992);
it("A should be 2", () => {
const nub = new YAXB(new YAXBParams(10, 666, 3, 4));
nub.calculatedParam = nub.prms.A;
nub.CalcSerie();
expect(nub.result.vCalc).toBe(2);
});
});
describe("Calc(): ", () => {
it("D should be 2.12847", () => {
const prms = new ConduiteDistribParams(3, // débit Q
undefined, // diamètre D
0.7, // perte de charge J
10, // Longueur de la conduite Lg
1e-6, // Viscosité dynamique Nu
);
const nub = new ConduiteDistrib(prms);
const r = nub.Calc("D", 0);
checkResult(r, 2.12847);
it("X should be 3", () => {
const nub = new YAXB(new YAXBParams(10, 2, 666, 4));
nub.calculatedParam = nub.prms.X;
nub.CalcSerie();
expect(nub.result.vCalc).toBe(3);
});
});
describe("Calc(): ", () => {
it("J should be 0.00814", () => {
const prms = new ConduiteDistribParams(3, // débit Q
1.2, // diamètre D
undefined, // perte de charge J
10, // Longueur de la conduite Lg
1e-6, // Viscosité dynamique Nu
);
it("B should be 4", () => {
const nub = new YAXB(new YAXBParams(10, 2, 3, 666));
nub.calculatedParam = nub.prms.B;
nub.CalcSerie();
expect(nub.result.vCalc).toBe(4);
});
const nub = new ConduiteDistrib(prms);
it("calc A with X = 0 should trigger error", () => {
const nub = new YAXB(new YAXBParams(10, 666, 0, 4));
nub.calculatedParam = nub.prms.A;
nub.CalcSerie();
expect(nub.result.ok).toBe(false);
expect(nub.result.resultElement.log.messages.length).toBe(1);
expect(nub.result.resultElement.log.messages[0].code).toBe(MessageCode.ERROR_DIVISION_BY_ZERO);
});
checkResult(nub.Calc("J", 0), 0.00814);
it("calc X with A = 0 should trigger error", () => {
const nub = new YAXB(new YAXBParams(10, 0, 666, 4));
nub.calculatedParam = nub.prms.X;
nub.CalcSerie();
expect(nub.result.ok).toBe(false);
expect(nub.result.resultElement.log.messages.length).toBe(1);
expect(nub.result.resultElement.log.messages[0].code).toBe(MessageCode.ERROR_DIVISION_BY_ZERO);
});
});
describe("Calc(): ", () => {
it("Lg should be 737.021", () => {
const prms = new ConduiteDistribParams(3, // débit Q
1.2, // diamètre D
0.6, // perte de charge J
undefined, // Longueur de la conduite Lg
1e-6, // Viscosité dynamique Nu
);
});
const nub = new ConduiteDistrib(prms);
describe("Link: ", () => {
checkResult(nub.Calc("Lg", 0), 737.021);
});
});
it("all parameters must be linkable to Y,A,X,B in both ways", () => {
const yaxb = new YAXB(new YAXBParams(10, 2, 3, 4));
const lo = new ParallelStructure(new ParallelStructureParams(1.2, 102, 101));
lo.addChild(CreateStructure(LoiDebit.GateCem88d, lo));
describe("Calc(): ", () => {
it("Nu should be 0.00295", () => {
const prms = new ConduiteDistribParams(3, // débit Q
1.2, // diamètre D
0.6, // perte de charge J
100, // Longueur de la conduite Lg
undefined, // Viscosité dynamique Nu
);
Session.getInstance().clear();
Session.getInstance().registerNubs([ yaxb, lo ]);
const nub = new ConduiteDistrib(prms);
// each YAXB param should be linkable to all ParallelStructures params
expect(Session.getInstance().getLinkableValues(yaxb.prms.Y).length).toBe(7);
expect(Session.getInstance().getLinkableValues(yaxb.prms.A).length).toBe(7);
expect(Session.getInstance().getLinkableValues(yaxb.prms.X).length).toBe(7);
expect(Session.getInstance().getLinkableValues(yaxb.prms.B).length).toBe(7);
checkResult(nub.Calc("Nu", 0), 0.00295);
// each ParallelStructures param should be linkable to all YAXB params
for (const p of lo.parameterIterator) {
expect(Session.getInstance().getLinkableValues(p).length).toBe(4);
}
});
});
});
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