Browse Source

move test code into executeTests function

main
Steven 1 year ago
parent
commit
8a32a63db7
  1. 78
      test.js

78
test.js

@ -178,39 +178,7 @@ function Assert(testName, thingsToCheck) {
return output;
}
//All the scenarios we could run into
function getScenarios(){
let useCases = []; //[generalCapIsEnabled, generalCap, capPresidence, applyPresidenceTo, oversightAction, rowCapIsEnabled, rowCap, tieBid, myBid];
useCases[0] = [GeneralCapIsEnabled, 300, Presidence.General, AppliesTo.All, Oversight.Win, !RowCapIsEnabled, null, 500, 350];
useCases[1] = [GeneralCapIsEnabled, 300, Presidence.General, AppliesTo.All, Oversight.Win, RowCapIsEnabled, 450 , 500, 350];
useCases[2] = [GeneralCapIsEnabled, 300, Presidence.General, AppliesTo.All, Oversight.Tie, !RowCapIsEnabled, null, 500, 350];
useCases[3] = [GeneralCapIsEnabled, 300, Presidence.General, AppliesTo.All, Oversight.Tie, RowCapIsEnabled, 450 , 500, 350];
return useCases;
}
//And what we expect from each scenario
function getExpectations(){
let expectedOutcomes = []; //[shouldApplyCap, reason, trueCap, capSource, myBid]);
expectedOutcomes[0] = [GeneralCapIsEnabled, 1, 300, Capsource.General, 300];
expectedOutcomes[1] = [GeneralCapIsEnabled, 1, 300, Capsource.General, 300];
expectedOutcomes[2] = [GeneralCapIsEnabled, 3, 300, Capsource.General, 300];
expectedOutcomes[3] = [GeneralCapIsEnabled, 4, 300, Capsource.General, 300];
return expectedOutcomes;
}
function getTest(testId) {
//TODO: THIS CODE IS AN IDEA AND IS NOT USED YET
let assertion = {};
assertion.id = testId;
assertion.given = useCases[testId];
assertion.expect = expectedCoutomes[testId];
}
//Setup our scenarios and expected values
let scenarios = getScenarios();
let expectations = getExpectations();
let verboseLevel = 1;
function executeTests(scenarios, expectations, verboseLevel) {
///////////////////////////////////////////////////////////////////////////////
//Run thru the scenarios
const scenariosCount = scenarios.length;
@ -287,3 +255,47 @@ if(allTestsPassed){
console.log(failCount+"/"+reasonsCount+" tests failed");
}
console.log("");
return allTestsPassed;
}
function getTest(testId) {
//TODO: THIS CODE IS AN IDEA AND IS NOT USED YET
let test = {};
test.id = testId;
test.given = getUseCases()[testId];
test.expect = getExpectedOutcomes()[testId];
return test;
}
//All the scenarios we could run into
function getUseCases(){
let useCases = []; //[generalCapIsEnabled, generalCap, capPresidence, applyPresidenceTo, oversightAction, rowCapIsEnabled, rowCap, tieBid, myBid];
useCases[0] = [GeneralCapIsEnabled, 300, Presidence.General, AppliesTo.All, Oversight.Win, !RowCapIsEnabled, null, 500, 350];
useCases[1] = [GeneralCapIsEnabled, 300, Presidence.General, AppliesTo.All, Oversight.Win, RowCapIsEnabled, 450 , 500, 350];
useCases[2] = [GeneralCapIsEnabled, 300, Presidence.General, AppliesTo.All, Oversight.Tie, !RowCapIsEnabled, null, 500, 350];
useCases[3] = [GeneralCapIsEnabled, 300, Presidence.General, AppliesTo.All, Oversight.Tie, RowCapIsEnabled, 450 , 500, 350];
return useCases;
}
//And what we expect from each scenario
function getExpectedOutcomes(){
let expectedOutcomes = []; //[shouldApplyCap, reason, trueCap, capSource, myBid]);
expectedOutcomes[0] = [GeneralCapIsEnabled, 1, 300, Capsource.General, 300];
expectedOutcomes[1] = [GeneralCapIsEnabled, 1, 300, Capsource.General, 300];
expectedOutcomes[2] = [GeneralCapIsEnabled, 3, 300, Capsource.General, 300];
expectedOutcomes[3] = [GeneralCapIsEnabled, 4, 300, Capsource.General, 300];
return expectedOutcomes;
}
//Setup our scenarios and expected values
const useCases = getUseCases();
const expectedOutcomes = getExpectedOutcomes();
const verboseLevel = 1;
const testResults = executeTests(useCases, expectedOutcomes, verboseLevel);

Loading…
Cancel
Save