Browse Source

Added getTrueCap & Tests for outcome NO CALLS YET

main
Steven 1 year ago
parent
commit
1fb2de882c
  1. 243
      tampermonkey.js
  2. 463
      test.js

243
tampermonkey.js

@ -344,21 +344,144 @@ function renderOption(value, selectedValue, displayValue) {
return optionHtml; return optionHtml;
} }
function getCapPresidenceOptions(selectedAction) {
const Presidence = Object.freeze({
General: "general",
Row: "row",
Highest: "highest",
Lowest: "lowest"
})
const AppliesTo = Object.freeze({
All: "all",
None: "none",
Capped: "capped",
Uncapped: "uncapped"
})
const Oversight = Object.freeze({
Win: "win",
Tie: "tie",
Watch: "watch",
Ignore: "ignore"
})
const Capsource = Object.freeze({
Row: "row",
General: "general"
})
const CapTrigger = Object.freeze({
None: "None",
General: "General",
Row: "Row"
})
function getTrueCap(isGeneralCapEnabled, isRowCapIsEnabled, presidenceValue, generalCapValue, rowCapValue){
//Our response object
function trueCap(trigger, value) {
let response = {};
response.trigger = trigger;
response.value = value;
return response;
}
trueCap.trigger = CapTrigger.None; //Used to identify which cap the trueCap value was derived from.
trueCap.value = null; //The actual calculated true cap
//Do some error handling to start off
if(isGeneralCapEnabled == true && generalCapValue == null) {
if(verboseLevel >= 1) {
console.warn("GeneralCap is enabled but the GeneralCapValue is not set - Acting as if GeneralCap was not enabled.");
}
isGeneralCapEnabled = false;
}
if(isRowCapIsEnabled == true && rowCapValue == null) {
if(verboseLevel >= 1) {
console.warn("RowCap is enabled but the RowCapValue is not set - Acting as if RowCap was not enabled.");
}
isRowCapIsEnabled = false;
}
//Now our actual logic begins
if(isGeneralCapEnabled == false && isRowCapIsEnabled == false) {
return trueCap(CapTrigger.None,null); //No cap available to return
}
if(isRowCapIsEnabled == true && rowCapValue == null) {
//console.warn("RowCap is enabled but the RowCapValue is not set");
return trueCap(CapTrigger.None,null); //No cap available to return
}
if(isGeneralCapEnabled == true) {
switch (presidenceValue) {
case Presidence.General:
//General wins
return trueCap(CapTrigger.General, generalCapValue);
case Presidence.Row:
if(isRowCapIsEnabled == true) {
//Row wins
return trueCap(CapTrigger.Row, rowCapValue);
}
return trueCap(CapTrigger.General, generalCapValue);
case Presidence.Highest:
if(isRowCapIsEnabled == true) {
//Figure out which is higher
if(rowCapValue > generalCapValue) {
//Row wins
return trueCap(CapTrigger.Row, rowCapValue);
}
}
return trueCap(CapTrigger.General, generalCapValue);;
case Presidence.Lowest:
if(isRowCapIsEnabled == true) {
if(rowCapValue < generalCapValue) {
//Row wins
return trueCap(CapTrigger.Row, rowCapValue);
}
}
return trueCap(CapTrigger.General, generalCapValue);;
default:
return trueCap(CapTrigger.General, generalCapValue);;
}
return trueCap(CapTrigger.General, generalCapValue);;
}
//If we made it here then generalCap is not enabled but the row cap may still be enabled
if(isRowCapIsEnabled == true) {
return trueCap(CapTrigger.Row, rowCapValue);
}
//We should never get here
return trueCap(CapTrigger.None, null);
}
function getCapPresidenceOptions(selectedOption) {
var optionsHtml = ""; var optionsHtml = "";
optionsHtml += renderOption("row", selectedAction, "Row Cap"); optionsHtml += renderOption(Presidence.Row, selectedOption, "Row Cap");
optionsHtml += renderOption("general", selectedAction, "General Cap"); optionsHtml += renderOption(Presidence.General, selectedOption, "General Cap");
optionsHtml += renderOption("highest", selectedAction, "Highest Cap"); optionsHtml += renderOption(Presidence.Highest, selectedOption, "Highest Cap");
optionsHtml += renderOption("lowest", selectedAction, "Lowest Cap"); optionsHtml += renderOption(Presidence.Lowest, selectedOption, "Lowest Cap");
return optionsHtml; return optionsHtml;
} }
function getOversightOptions(countyId, selectedAction) { function getOversightOptions(countyId, selectedOption) {
var optionsHtml = ""; var optionsHtml = "";
optionsHtml += renderOption("win", selectedAction); optionsHtml += renderOption(Oversight.Win, selectedOption);
optionsHtml += renderOption("tie", selectedAction); optionsHtml += renderOption(Oversight.Tie, selectedOption);
optionsHtml += renderOption("watch",selectedAction); optionsHtml += renderOption(Oversight.Watch, selectedOption);
optionsHtml += renderOption("ignore",selectedAction); optionsHtml += renderOption(Oversight.Ignore, selectedOption);
return optionsHtml; return optionsHtml;
} }
@ -378,7 +501,7 @@ function upsertOversight(countyOversightJson) {
function convertToOversightJson(countyInfoJson, action, isBidCapEnabled){ function convertToOversightJson(countyInfoJson, action, isBidCapEnabled){
const countyInfo = { const countyInfo = {
"id":countyInfoJson.id, "id": countyInfoJson.id,
"bidCap": countyInfoJson.bidCap, "bidCap": countyInfoJson.bidCap,
"isBidCapEnabled": isBidCapEnabled, "isBidCapEnabled": isBidCapEnabled,
"action": action "action": action
@ -403,21 +526,6 @@ function getBidCapReasonIcon(reason) {
} }
function getBidCapReason(tieBid, myBid, oversightAction, rowCapIsEnabled, rowCap, generalCapIsEnabled, generalCap, capPresidence, applyPresidenceTo) { function getBidCapReason(tieBid, myBid, oversightAction, rowCapIsEnabled, rowCap, generalCapIsEnabled, generalCap, capPresidence, applyPresidenceTo) {
const Presidence_General = "general";
const Presidence_Row = "row";
const Presidence_Highest = "highest";
const Presidence_Lowest = "lowest";
const AppliesTo_All = "all";
const AppliesTo_None = "none";
const AppliesTo_Capped = "capped";
const AppliesTo_Uncapped = "uncapped";
const Oversight_Win = "win";
const Oversight_Tie = "tie";
const Oversight_Watch = "watch";
const Oversight_Ignore = "ignore";
const Capsource_Row = "row";
const Capsource_General = "general";
let tieBidNum = number(tieBid); let tieBidNum = number(tieBid);
let winBidNum = number(tieBid) + 25; let winBidNum = number(tieBid) + 25;
let generalCapNum = number(generalCap); let generalCapNum = number(generalCap);
@ -434,15 +542,15 @@ function getBidCapReason(tieBid, myBid, oversightAction, rowCapIsEnabled, rowCap
//WIP - LOTS of rules here - these are just the beginning. //WIP - LOTS of rules here - these are just the beginning.
if(generalCapIsEnabled) { if(generalCapIsEnabled) {
if(capPresidence == Presidence_General) { if(capPresidence == Presidence.General) {
if(applyPresidenceTo == AppliesTo_All) { if(applyPresidenceTo == AppliesTo.All) {
results.shouldApplyCap = false; results.shouldApplyCap = false;
results.capSource = Capsource_General; results.capSource = Capsource.General;
results.trueCap = generalCapNum; results.trueCap = generalCapNum;
switch(oversightAction) { switch(oversightAction) {
case Oversight_Win: case Oversight.Win:
if(winBidNum > generalCapNum) { if(winBidNum > generalCapNum) {
results.shouldApplyCap = true; results.shouldApplyCap = true;
results.reason = 1; results.reason = 1;
@ -454,7 +562,7 @@ function getBidCapReason(tieBid, myBid, oversightAction, rowCapIsEnabled, rowCap
results.myBid = myBidNum; results.myBid = myBidNum;
break; break;
case Oversight_Tie: case Oversight.Tie:
if(tieBidNum > generalCapNum) { if(tieBidNum > generalCapNum) {
results.shouldApplyCap = true; results.shouldApplyCap = true;
results.reason = 3; results.reason = 3;
@ -466,11 +574,11 @@ function getBidCapReason(tieBid, myBid, oversightAction, rowCapIsEnabled, rowCap
results.myBid = myBidNum; results.myBid = myBidNum;
break; break;
case Oversight_Watch: case Oversight.Watch:
results.reason = 5; results.reason = 5;
break; break;
case Oversight_Ignore: case Oversight.Ignore:
results.reason = 6; results.reason = 6;
break; break;
@ -479,24 +587,24 @@ function getBidCapReason(tieBid, myBid, oversightAction, rowCapIsEnabled, rowCap
} }
return results; return results;
} }
else if(applyPresidenceTo == AppliesTo_None){ else if(applyPresidenceTo == AppliesTo.None){
} }
else if(applyPresidenceTo == AppliesTo_Capped){ else if(applyPresidenceTo == AppliesTo.Capped){
} }
else if(applyPresidenceTo == AppliesTo_Uncapped){ else if(applyPresidenceTo == AppliesTo.Uncapped){
} }
return results; return results;
} }
else if(capPresidence == Presidence_Row) { else if(capPresidence == Presidence.Row) {
return results; return results;
} }
else if(capPresidence == Presidence_Highest){ else if(capPresidence == Presidence.Highest){
return results; return results;
} }
else if(capPresidence == Presidence_Lowest){ else if(capPresidence == Presidence.Lowest){
return results; return results;
} }
} }
@ -504,12 +612,12 @@ function getBidCapReason(tieBid, myBid, oversightAction, rowCapIsEnabled, rowCap
//This means rowCaps are the winners if they are enabled. //This means rowCaps are the winners if they are enabled.
if(rowCapIsEnabled) { if(rowCapIsEnabled) {
switch(oversightAction) { switch(oversightAction) {
case Oversight_Win: case Oversight.Win:
if(winBidNum > rowCapNum) { if(winBidNum > rowCapNum) {
results.shouldApplyCap = true; results.shouldApplyCap = true;
results.reason = 101; results.reason = 101;
results.trueCap = rowCapNum; results.trueCap = rowCapNum;
results.capSource = Capsource_Row; results.capSource = Capsource.Row;
results.myBid = rowCapNum; results.myBid = rowCapNum;
return results; return results;
} }
@ -517,16 +625,16 @@ function getBidCapReason(tieBid, myBid, oversightAction, rowCapIsEnabled, rowCap
results.shouldApplyCap = false; results.shouldApplyCap = false;
results.reason = 102; results.reason = 102;
results.trueCap = rowCapNum; results.trueCap = rowCapNum;
results.capSource = Capsource_Row; results.capSource = Capsource.Row;
results.myBid = myBidNum; results.myBid = myBidNum;
break; break;
case Oversight_Tie: case Oversight.Tie:
if(tieBidNum > rowCapNum) { if(tieBidNum > rowCapNum) {
results.shouldApplyCap = true; results.shouldApplyCap = true;
results.reason = 103; results.reason = 103;
results.trueCap = rowCapNum; results.trueCap = rowCapNum;
results.capSource = Capsource_Row; results.capSource = Capsource.Row;
results.myBid = rowCapNum; results.myBid = rowCapNum;
return results; return results;
} }
@ -534,23 +642,23 @@ function getBidCapReason(tieBid, myBid, oversightAction, rowCapIsEnabled, rowCap
results.shouldApplyCap = false; results.shouldApplyCap = false;
results.reason = 104; results.reason = 104;
results.trueCap = rowCapNum; results.trueCap = rowCapNum;
results.capSource = Capsource_Row; results.capSource = Capsource.Row;
results.myBid = myBidNum; results.myBid = myBidNum;
break; break;
case Oversight_Watch: case Oversight.Watch:
results.shouldApplyCap = false; results.shouldApplyCap = false;
results.reason = 105; results.reason = 105;
results.trueCap = null; results.trueCap = null;
results.capSource = Capsource_Row; results.capSource = Capsource.Row;
results.myBid = myBidNum; results.myBid = myBidNum;
break; break;
case Oversight_Ignore: case Oversight.Ignore:
results.shouldApplyCap = false; results.shouldApplyCap = false;
results.reason = 106; results.reason = 106;
results.trueCap = null; results.trueCap = null;
results.capSource = Capsource_Row; results.capSource = Capsource.Row;
results.myBid = myBidNum; results.myBid = myBidNum;
break; break;
default: default:
@ -600,19 +708,19 @@ function injectOversight(countyId, action) {
//Begin TODO: move this code block elsewhere IT IS WIP //Begin TODO: move this code block elsewhere IT IS WIP
const settingsCapPresidence = alwaysWinSettings.capPresidence; const settingsCapPresidence = alwaysWinSettings.capPresidence;
const settings_Presidence_RowCap = (settingsCapPresidence == "row"); const settings_Presidence_RowCap = (settingsCapPresidence == Presidence.Row);
const settings_Presidence_GeneralCap = (settingsCapPresidence == "generl"); const settings_Presidence_GeneralCap = (settingsCapPresidence == Presidence.General);
const settings_Presidence_HighestCap = (settingsCapPresidence == "highest"); const settings_Presidence_HighestCap = (settingsCapPresidence == Presidence.Highest);
const settings_Presidence_LowestCap = (settingsCapPresidence == "lowest"); const settings_Presidence_LowestCap = (settingsCapPresidence == Presidence.Lowest);
const settingsGeneralCapAppliesTo = "capped" //[n,a,c,u] const settingsGeneralCapAppliesTo = Presidence.General
const settings_GeneralCapAppliesTo_None = (settingsGeneralCapAppliesTo == "none")//None of the const settings_GeneralCapAppliesTo_None = (settingsGeneralCapAppliesTo == AppliesTo.None)//None of the
const settings_GeneralCapAppliesTo_All = (settingsGeneralCapAppliesTo == "all")//All const settings_GeneralCapAppliesTo_All = (settingsGeneralCapAppliesTo == AppliesTo.All)//All
const settings_GeneralCapAppliesTo_Capped = (settingsGeneralCapAppliesTo == "capped")//Capped Only const settings_GeneralCapAppliesTo_Capped = (settingsGeneralCapAppliesTo == AppliesTo.Capped)//Capped Only
const settings_GeneralCapAppliesTo_Uncapped = (settingsGeneralCapAppliesTo == "uncapped")//UnCapped Only const settings_GeneralCapAppliesTo_Uncapped = (settingsGeneralCapAppliesTo == AppliesTo_Uncapped)//UnCapped Only
const rowCapControlsShouldBeVisible = (action == "win" || action == "tie"); //TODO write logic to determine if the enable Bidcap checkbox and words should be visible const rowCapControlsShouldBeVisible = (action == Oversight.Win || action == Oversight.Tie); //TODO write logic to determine if the enable Bidcap checkbox and words should be visible
const rowCapCheckboxShouldBeVisible = (action == "win" || action == "tie"); //TODO: write logic const rowCapCheckboxShouldBeVisible = (action == Oversight.Win || action == Oversight.Tie); //TODO: write logic
const rowCapCheckboxShouldBeDisabled = false; //TODO: write logic const rowCapCheckboxShouldBeDisabled = false; //TODO: write logic
const rowCapCheckboxShouldBeChecked = false; //TODO: write logic const rowCapCheckboxShouldBeChecked = false; //TODO: write logic
@ -620,7 +728,8 @@ function injectOversight(countyId, action) {
const rowCapInputIsBeingOverridden = settings_Presidence_GeneralCap; //TODO: write logic const rowCapInputIsBeingOverridden = settings_Presidence_GeneralCap; //TODO: write logic
const rowCapInputShouldBeDisabled = (rowCapInputIsBeingOverridden || !rowCapCheckboxShouldBeChecked); //TODO: write logic const rowCapInputShouldBeDisabled = (rowCapInputIsBeingOverridden || !rowCapCheckboxShouldBeChecked); //TODO: write logic
const trueCap = alwaysWinSettings.generalCap; //countyJson.bidCap; //TODO actually calcuate instead of reading from settings const trueCap = getTrueCap(isGeneralCapEnabled,) alwaysWinSettings.generalCap; //countyJson.bidCap; //TODO actually calcuate instead of reading from settings
//const trueCap = getTrueCap(isGeneralCapEnabled,isRowCapIsEnabled,presidenceValue,generalCapNum,rowCapNum); //TODO: Uncomment this line once I get the params right.
const capIsCurrentlyBeingAppliedToBid = countyJson.bid > Number(trueCap); const capIsCurrentlyBeingAppliedToBid = countyJson.bid > Number(trueCap);
//End TODO //End TODO
@ -745,16 +854,16 @@ jQuery(window).on('load',function() {
const countyInfoJson = getCountyInfo(currentEntity.id); const countyInfoJson = getCountyInfo(currentEntity.id);
//console.log(currentEntity); //console.log(currentEntity);
switch (currentEntity.action) { switch (currentEntity.action) {
case "win": case Oversight.Win:
winCounty(countyInfoJson,true); winCounty(countyInfoJson,true);
break; break;
case "tie": case Oversight.Tie:
tieCounty(countyInfoJson,true); tieCounty(countyInfoJson,true);
break; break;
case "watch": case Oversight.Watch:
watchCounty(countyInfoJson,false); watchCounty(countyInfoJson,false);
break; break;
case "ignore": case Oversight.Ignore:
ignoreCounty(countyInfoJson, false); ignoreCounty(countyInfoJson, false);
break; break;
default: default:

463
test.js

@ -1,4 +1,6 @@
//Setup some enum's /////////////////////////////////////////////////////////////////
////////BEGIN THIS CODE LIVES IN TAMPERMONKEY.JS = THIS IS A COPY
const Presidence = Object.freeze({ const Presidence = Object.freeze({
General: "general", General: "general",
Row: "row", Row: "row",
@ -25,6 +27,105 @@ const Capsource = Object.freeze({
General: "general" General: "general"
}) })
const CapTrigger = Object.freeze({
None: "None",
General: "General",
Row: "Row"
})
function getTrueCap(isGeneralCapEnabled, isRowCapIsEnabled, presidenceValue, generalCapValue, rowCapValue){
//Our response object
function trueCap(trigger, value) {
let response = {};
response.trigger = trigger;
response.value = value;
return response;
}
trueCap.trigger = CapTrigger.None; //Used to identify which cap the trueCap value was derived from.
trueCap.value = null; //The actual calculated true cap
//Do some error handling to start off
if(isGeneralCapEnabled == true && generalCapValue == null) {
if(verboseLevel >= 1) {
console.warn("GeneralCap is enabled but the GeneralCapValue is not set - Acting as if GeneralCap was not enabled.");
}
isGeneralCapEnabled = false;
}
if(isRowCapIsEnabled == true && rowCapValue == null) {
if(verboseLevel >= 1) {
console.warn("RowCap is enabled but the RowCapValue is not set - Acting as if RowCap was not enabled.");
}
isRowCapIsEnabled = false;
}
//Now our actual logic begins
if(isGeneralCapEnabled == false && isRowCapIsEnabled == false) {
return trueCap(CapTrigger.None,null); //No cap available to return
}
if(isRowCapIsEnabled == true && rowCapValue == null) {
//console.warn("RowCap is enabled but the RowCapValue is not set");
return trueCap(CapTrigger.None,null); //No cap available to return
}
if(isGeneralCapEnabled == true) {
switch (presidenceValue) {
case Presidence.General:
//General wins
return trueCap(CapTrigger.General, generalCapValue);
case Presidence.Row:
if(isRowCapIsEnabled == true) {
//Row wins
return trueCap(CapTrigger.Row, rowCapValue);
}
return trueCap(CapTrigger.General, generalCapValue);
case Presidence.Highest:
if(isRowCapIsEnabled == true) {
//Figure out which is higher
if(rowCapValue > generalCapValue) {
//Row wins
return trueCap(CapTrigger.Row, rowCapValue);
}
}
return trueCap(CapTrigger.General, generalCapValue);;
case Presidence.Lowest:
if(isRowCapIsEnabled == true) {
if(rowCapValue < generalCapValue) {
//Row wins
return trueCap(CapTrigger.Row, rowCapValue);
}
}
return trueCap(CapTrigger.General, generalCapValue);;
default:
return trueCap(CapTrigger.General, generalCapValue);;
}
return trueCap(CapTrigger.General, generalCapValue);;
}
//If we made it here then generalCap is not enabled but the row cap may still be enabled
if(isRowCapIsEnabled == true) {
return trueCap(CapTrigger.Row, rowCapValue);
}
//We should never get here
return trueCap(CapTrigger.None, null);
}
////////END THIS CODE LIVES IN TAMPERMONKEY.JS = THIS IS A COPY
///////////////////////////////////////////////////////////////
//Setup some enum's
const TestResult = Object.freeze({ const TestResult = Object.freeze({
Pass: "Pass", Pass: "Pass",
Fail: "Fail" Fail: "Fail"
@ -1138,89 +1239,24 @@ function getExpectedOutcomes_where_only_a_GeneralCap_can_be_triggered(){
return expectedOutcomes; return expectedOutcomes;
} }
function getTrueCap(isGeneralCapEnabled, isRowCapIsEnabled, presidenceValue, generalCapValue, rowCapValue){ function getTrueCapAsTestResult(isGeneralCapEnabled, isRowCapIsEnabled, presidenceValue, generalCapValue, rowCapValue){
//Do some error handling to start off //This is a helper method to help make testing results a bit easier.
if(isGeneralCapEnabled == true && generalCapValue == null) { const trueCap = getTrueCap(isGeneralCapEnabled, isRowCapIsEnabled, presidenceValue, generalCapValue, rowCapValue)
if(verboseLevel >= 1) { return [trueCap.trigger, trueCap.value];
console.warn("GeneralCap is enabled but the GeneralCapValue is not set - Acting as if GeneralCap was not enabled."); }
}
isGeneralCapEnabled = false;
}
if(isRowCapIsEnabled == true && rowCapValue == null) { function assertEqual(given, expected) {
if(verboseLevel >= 1) { if(typeof(given) === "object"){
console.warn("RowCap is enabled but the RowCapValue is not set - Acting as if RowCap was not enabled."); if(Array.isArray(given)) {
given+="";
} }
isRowCapIsEnabled = false;
}
//Now our actual logic begins
if(isGeneralCapEnabled == false && isRowCapIsEnabled == false) {
return null; //No cap available to return
}
if(isRowCapIsEnabled == true && rowCapValue == null) {
//console.warn("RowCap is enabled but the RowCapValue is not set");
return null;
} }
if(typeof(expected) === "object"){
if(isGeneralCapEnabled == true) { if(Array.isArray(expected)) {
switch (presidenceValue) { expected+="";
case Presidence.General:
//General wins
return generalCapValue;
case Presidence.Row:
if(isRowCapIsEnabled == true) {
//Row wins
return rowCapValue;
}
return generalCapValue;
case Presidence.Highest:
if(isRowCapIsEnabled == true) {
//Figure out which is higher
if(rowCapValue > generalCapValue) {
//Row wins
return rowCapValue;
}
}
return generalCapValue;
case Presidence.Lowest:
if(isRowCapIsEnabled == true) {
if(rowCapValue < generalCapValue) {
//Row wins
return rowCapValue;
}
}
return generalCapValue;
default:
return generalCapValue;
} }
return generalCapValue;
} }
//If we made it here then generalCap is not enabled but the row cap may still be enabled
if(isRowCapIsEnabled == true) {
return rowCapValue;
}
//We should never get here
return null;
}
//Setup our scenarios and expected values
const useCases = getUseCases_where_only_a_GeneralCap_can_be_triggered();
const expectedOutcomes = getExpectedOutcomes_where_only_a_GeneralCap_can_be_triggered();
const verboseLevel = 0;
//const testResults = executeTests(useCases, expectedOutcomes, verboseLevel);
function assertEqual(given, expected) {
let areEqual = (given == expected); let areEqual = (given == expected);
let retVal = {}; let retVal = {};
retVal.details = given +"=="+ expected; retVal.details = given +"=="+ expected;
@ -1239,138 +1275,210 @@ function print(name, test){
function test_GetTrueCaps_ReturnsExpectedValues(){ function test_GetTrueCaps_ReturnsExpectedValues(){
//#General Presidence //#General Presidence
//Neither caps enabled //Neither caps enabled
print("a1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.General, null, null), null)); print("a1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.General, null, null).value, null));
print("a2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.General, null, 400), null)); print("a2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.General, null, 400).value, null));
print("a3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.General, 300, null), null)); print("a3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.General, 300, null).value, null));
print("a4", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.General, 300, 200), null)); print("a4", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.General, 300, 200).value, null));
print("a5", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.General, 300, 300), null)); print("a5", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.General, 300, 300).value, null));
print("a6", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.General, 300, 400), null)); print("a6", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.General, 300, 400).value, null));
//Only General cap enabled ***** //Only General cap enabled *****
print("b1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.General, null, null), null)); //Invalid situation -> a1 print("b1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.General, null, null).value, null)); //Invalid situation -> a1
print("b2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.General, null, 400), null)); //Invalid situation -> a2 print("b2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.General, null, 400).value, null)); //Invalid situation -> a2
print("b3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.General, 300, null), 300)); print("b3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.General, 300, null).value, 300));
print("b4", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.General, 300, 200), 300)); print("b4", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.General, 300, 200).value, 300));
print("b5", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.General, 300, 300), 300)); print("b5", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.General, 300, 300).value, 300));
print("b6", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.General, 300, 400), 300)); print("b6", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.General, 300, 400).value, 300));
//Both Caps are enabled ***** ***** ^^^^^ //Both Caps are enabled ***** ***** ^^^^^
print("c1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.General, null, null), null)); //Invalid situation -> a1 print("c1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.General, null, null).value, null)); //Invalid situation -> a1
print("c2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.General, null, 400), 400)); //Invalid situation -> d2 print("c2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.General, null, 400).value, 400)); //Invalid situation -> d2
print("c3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.General, 300, null), 300)); //Invalid situation -> b3 print("c3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.General, 300, null).value, 300)); //Invalid situation -> b3
print("c4", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.General, 300, 200), 300)); print("c4", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.General, 300, 200).value, 300));
print("c5", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.General, 300, 300), 300)); print("c5", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.General, 300, 300).value, 300));
print("c6", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.General, 300, 400), 300)); print("c6", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.General, 300, 400).value, 300));
//Only Row Cap enabled ***** //Only Row Cap enabled *****
print("d1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.General, null, null), null)); //Invalid situation -> a1 print("d1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.General, null, null).value, null)); //Invalid situation -> a1
print("d2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.General, null, 400), 400)); print("d2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.General, null, 400).value, 400));
print("d3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.General, 300, null), null)); //Invalid situation -> a3 print("d3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.General, 300, null).value, null)); //Invalid situation -> a3
print("d4", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.General, 300, 200), 200)); print("d4", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.General, 300, 200).value, 200));
print("d5", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.General, 300, 300), 300)); print("d5", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.General, 300, 300).value, 300));
print("d6", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.General, 300, 400), 400)); print("d6", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.General, 300, 400).value, 400));
//#Row Presidence //#Row Presidence
//Neither caps enabled //Neither caps enabled
print("a1.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Row, null, null), null)); print("a1.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Row, null, null).value, null));
print("a2.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Row, null, 400), null)); print("a2.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Row, null, 400).value, null));
print("a3.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Row, 300, null), null)); print("a3.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Row, 300, null).value, null));
print("a4.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Row, 300, 200), null)); print("a4.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Row, 300, 200).value, null));
print("a5.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Row, 300, 300), null)); print("a5.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Row, 300, 300).value, null));
print("a6.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Row, 300, 400), null)); print("a6.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Row, 300, 400).value, null));
//Only General cap enabled ***** //Only General cap enabled *****
print("b1.1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Row, null, null), null)); //Invalid situation -> a1.1 print("b1.1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Row, null, null).value, null)); //Invalid situation -> a1.1
print("b2.1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Row, null, 400), null)); //Invalid situation -> a2.1 print("b2.1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Row, null, 400).value, null)); //Invalid situation -> a2.1
print("b3.1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Row, 300, null), 300)); print("b3.1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Row, 300, null).value, 300));
print("b4.1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Row, 300, 200), 300)); print("b4.1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Row, 300, 200).value, 300));
print("b5.1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Row, 300, 300), 300)); print("b5.1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Row, 300, 300).value, 300));
print("b6.1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Row, 300, 400), 300)); print("b6.1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Row, 300, 400).value, 300));
//Both Caps are enabled ***** ***** ^^^^^ //Both Caps are enabled ***** ***** ^^^^^
print("e1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Row, null, null), null)); //Invalid situation -> a1.1 print("e1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Row, null, null).value, null)); //Invalid situation -> a1.1
print("e2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Row, null, 400), 400)); //Invalid situation -> d2.1 print("e2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Row, null, 400).value, 400)); //Invalid situation -> d2.1
print("e3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Row, 300, null), 300)); //Invalid situation -> b3.1 print("e3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Row, 300, null).value, 300)); //Invalid situation -> b3.1
print("e4", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Row, 300, 200), 200)); print("e4", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Row, 300, 200).value, 200));
print("e5", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Row, 300, 300), 300)); print("e5", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Row, 300, 300).value, 300));
print("e6", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Row, 300, 400), 400)); print("e6", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Row, 300, 400).value, 400));
//Only Row Cap enabled ***** //Only Row Cap enabled *****
print("d1.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Row, null, null), null)); //Invalid situation -> a1.1 print("d1.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Row, null, null).value, null)); //Invalid situation -> a1.1
print("d2.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Row, null, 400), 400)); print("d2.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Row, null, 400).value, 400));
print("d3.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Row, 300, null), null)); //Invalid situation -> a3.1 print("d3.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Row, 300, null).value, null)); //Invalid situation -> a3.1
print("d4.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Row, 300, 200), 200)); print("d4.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Row, 300, 200).value, 200));
print("d5.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Row, 300, 300), 300)); print("d5.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Row, 300, 300).value, 300));
print("d6.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Row, 300, 400), 400)); print("d6.1", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Row, 300, 400).value, 400));
//#Highest Presidence //#Highest Presidence
//Neither caps enabled //Neither caps enabled
print("a1.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Highest, null, null), null)); print("a1.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Highest, null, null).value, null));
print("a2.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Highest, null, 400), null)); print("a2.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Highest, null, 400).value, null));
print("a3.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Highest, 300, null), null)); print("a3.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Highest, 300, null).value, null));
print("a4.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Highest, 300, 200), null)); print("a4.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Highest, 300, 200).value, null));
print("a5.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Highest, 300, 300), null)); print("a5.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Highest, 300, 300).value, null));
print("a6.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Highest, 300, 400), null)); print("a6.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Highest, 300, 400).value, null));
//Only General cap enabled ***** //Only General cap enabled *****
print("b1.2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Highest, null, null), null)); //Invalid situation -> a1.2 print("b1.2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Highest, null, null).value, null)); //Invalid situation -> a1.2
print("b2.2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Highest, null, 400), null)); //Invalid situation -> a2.2 print("b2.2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Highest, null, 400).value, null)); //Invalid situation -> a2.2
print("b3.2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Highest, 300, null), 300)); print("b3.2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Highest, 300, null).value, 300));
print("b4.2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Highest, 300, 200), 300)); print("b4.2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Highest, 300, 200).value, 300));
print("b5.2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Highest, 300, 300), 300)); print("b5.2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Highest, 300, 300).value, 300));
print("b6.2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Highest, 300, 400), 300)); print("b6.2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Highest, 300, 400).value, 300));
//Both Caps are enabled ***** ***** ^^^^^ //Both Caps are enabled ***** ***** ^^^^^
print("f1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Highest, null, null), null)); //Invalid situation -> a1.2 print("f1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Highest, null, null).value, null)); //Invalid situation -> a1.2
print("f2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Highest, null, 400), 400)); //Invalid situation -> d2.2 print("f2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Highest, null, 400).value, 400)); //Invalid situation -> d2.2
print("f3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Highest, 300, null), 300)); //Invalid situation -> b3.2 print("f3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Highest, 300, null).value, 300)); //Invalid situation -> b3.2
print("f4", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Highest, 300, 200), 300)); print("f4", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Highest, 300, 200).value, 300));
print("f5", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Highest, 300, 300), 300)); print("f5", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Highest, 300, 300).value, 300));
print("f6", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Highest, 300, 400), 400)); print("f6", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Highest, 300, 400).value, 400));
//Only Row Cap enabled ***** //Only Row Cap enabled *****
print("d1.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Highest, null, null), null)); //Invalid situation -> a1.2 print("d1.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Highest, null, null).value, null)); //Invalid situation -> a1.2
print("d2.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Highest, null, 400), 400)); print("d2.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Highest, null, 400).value, 400));
print("d3.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Highest, 300, null), null)); //Invalid situation => a3.2 print("d3.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Highest, 300, null).value, null)); //Invalid situation => a3.2
print("d4.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Highest, 300, 200), 200)); print("d4.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Highest, 300, 200).value, 200));
print("d5.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Highest, 300, 300), 300)); print("d5.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Highest, 300, 300).value, 300));
print("d6.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Highest, 300, 400), 400)); print("d6.2", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Highest, 300, 400).value, 400));
//#Lowest Presidence //#Lowest Presidence
//Neither caps enabled //Neither caps enabled
print("a1.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Lowest, null, null), null)); print("a1.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Lowest, null, null).value, null));
print("a2.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Lowest, null, 400), null)); print("a2.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Lowest, null, 400).value, null));
print("a3.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Lowest, 300, null), null)); print("a3.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Lowest, 300, null).value, null));
print("a4.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Lowest, 300, 200), null)); print("a4.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Lowest, 300, 200).value, null));
print("a5.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Lowest, 300, 300), null)); print("a5.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Lowest, 300, 300).value, null));
print("a6.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Lowest, 300, 400), null)); print("a6.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.Lowest, 300, 400).value, null));
//Only General cap enabled ***** //Only General cap enabled *****
print("b1.3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Lowest, null, null), null)); //Invalid situation -> a1.3 print("b1.3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Lowest, null, null).value, null)); //Invalid situation -> a1.3
print("b2.3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Lowest, null, 400), null)); //Invalid situation -> a2.3 print("b2.3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Lowest, null, 400).value, null)); //Invalid situation -> a2.3
print("b3.3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Lowest, 300, null), 300)); print("b3.3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Lowest, 300, null).value, 300));
print("b4.3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Lowest, 300, 200), 300)); print("b4.3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Lowest, 300, 200).value, 300));
print("b5.3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Lowest, 300, 300), 300)); print("b5.3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Lowest, 300, 300).value, 300));
print("b6.3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Lowest, 300, 400), 300)); print("b6.3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.Lowest, 300, 400).value, 300));
//Both Caps are enabled ***** ***** ^^^^^ //Both Caps are enabled ***** ***** ^^^^^
print("g1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Lowest, null, null), null)); //Invalid situation -> a1.3 print("g1", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Lowest, null, null).value, null)); //Invalid situation -> a1.3
print("g2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Lowest, null, 400), 400)); //Invalid situation -> d2.3 print("g2", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Lowest, null, 400).value, 400)); //Invalid situation -> d2.3
print("g3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Lowest, 300, null), 300)); //Invalid situation -> b3.3 print("g3", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Lowest, 300, null).value, 300)); //Invalid situation -> b3.3
print("g4", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Lowest, 300, 200), 200)); print("g4", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Lowest, 300, 200).value, 200));
print("g5", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Lowest, 300, 300), 300)); print("g5", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Lowest, 300, 300).value, 300));
print("g6", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Lowest, 300, 400), 300)); print("g6", assertEqual(getTrueCap(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Lowest, 300, 400).value, 300));
//Only Row Cap enabled ***** //Only Row Cap enabled *****
print("d1.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Lowest, null, null), null)); //Invalid situation -> a1.3 print("d1.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Lowest, null, null).value, null)); //Invalid situation -> a1.3
print("d2.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Lowest, null, 400), 400)); print("d2.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Lowest, null, 400).value, 400));
print("d3.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Lowest, 300, null), null)); //Invalid situation -> a3.3 print("d3.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Lowest, 300, null).value, null)); //Invalid situation -> a3.3
print("d4.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Lowest, 300, 200), 200)); print("d4.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Lowest, 300, 200).value, 200));
print("d5.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Lowest, 300, 300), 300)); print("d5.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Lowest, 300, 300).value, 300));
print("d6.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Lowest, 300, 400), 400)); print("d6.3", assertEqual(getTrueCap(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.Lowest, 300, 400).value, 400));
console.log("");
///////
//#INCLUDE CAPTRIGGER IN THE TESTS
//#General Presidence
//Neither caps enabled
print("a1", assertEqual(getTrueCapAsTestResult(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.General, null, null), [CapTrigger.None,null]));
print("a2", assertEqual(getTrueCapAsTestResult(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.General, null, 400), [CapTrigger.None,null]));
print("a3", assertEqual(getTrueCapAsTestResult(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.General, 300, null), [CapTrigger.None,null]));
print("a4", assertEqual(getTrueCapAsTestResult(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.General, 300, 200), [CapTrigger.None,null]));
print("a5", assertEqual(getTrueCapAsTestResult(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.General, 300, 300), [CapTrigger.None,null]));
print("a6", assertEqual(getTrueCapAsTestResult(GeneralCapNotEnabled, RowCapNotEnabled, Presidence.General, 300, 400), [CapTrigger.None,null]));
//Only General cap enabled *****
print("b1", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.General, null, null), [CapTrigger.None,null])); //Invalid situation -> a1
print("b2", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.General, null, 400), [CapTrigger.None,null])); //Invalid situation -> a2
print("b3", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.General, 300, null), [CapTrigger.General,300]));
print("b4", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.General, 300, 200), [CapTrigger.General,300]));
print("b5", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.General, 300, 300), [CapTrigger.General,300]));
print("b6", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapNotEnabled, Presidence.General, 300, 400), [CapTrigger.General,300]));
//Both Caps are enabled ***** ***** ^^^^^
print("c1", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.General, null, null), [CapTrigger.None,null])); //Invalid situation -> a1
print("c2", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.General, null, 400), [CapTrigger.Row,400])); //Invalid situation -> d2
print("c3", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.General, 300, null), [CapTrigger.General,300])); //Invalid situation -> b3
print("c4", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.General, 300, 200), [CapTrigger.General,300]));
print("c5", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.General, 300, 300), [CapTrigger.General,300]));
print("c6", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.General, 300, 400), [CapTrigger.General,300]));
//Only Row Cap enabled *****
print("d1", assertEqual(getTrueCapAsTestResult(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.General, null, null), [CapTrigger.None,null])); //Invalid situation -> a1
print("d2", assertEqual(getTrueCapAsTestResult(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.General, null, 400), [CapTrigger.Row,400]));
print("d3", assertEqual(getTrueCapAsTestResult(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.General, 300, null), [CapTrigger.None,null])); //Invalid situation -> a3
print("d4", assertEqual(getTrueCapAsTestResult(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.General, 300, 200), [CapTrigger.Row,200]));
print("d5", assertEqual(getTrueCapAsTestResult(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.General, 300, 300), [CapTrigger.Row,300]));
print("d6", assertEqual(getTrueCapAsTestResult(GeneralCapNotEnabled, RowCapIsEnabled, Presidence.General, 300, 400), [CapTrigger.Row,400]));
//#Row Presidence
//Both Caps are enabled ***** ***** ^^^^^
print("e1", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Row, null, null), [CapTrigger.None,null])); //Invalid situation -> a1.1
print("e2", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Row, null, 400), [CapTrigger.Row,400])); //Invalid situation -> d2.1
print("e3", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Row, 300, null), [CapTrigger.General,300])); //Invalid situation -> b3.1
print("e4", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Row, 300, 200), [CapTrigger.Row,200]));
print("e5", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Row, 300, 300), [CapTrigger.Row,300]));
print("e6", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Row, 300, 400), [CapTrigger.Row,400]));
//#Highest Presidence
//Both Caps are enabled ***** ***** ^^^^^
print("f1", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Highest, null, null), [CapTrigger.None,null])); //Invalid situation -> a1.2
print("f2", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Highest, null, 400), [CapTrigger.Row,400])); //Invalid situation -> d2.2
print("f3", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Highest, 300, null), [CapTrigger.General,300])); //Invalid situation -> b3.2
print("f4", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Highest, 300, 200), [CapTrigger.General,300]));
print("f5", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Highest, 300, 300), [CapTrigger.General,300]));
print("f6", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Highest, 300, 400), [CapTrigger.Row,400]));
//#Lowest Presidence
//Both Caps are enabled ***** ***** ^^^^^
print("g1", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Lowest, null, null), [CapTrigger.None,null])); //Invalid situation -> a1.3
print("g2", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Lowest, null, 400), [CapTrigger.Row,400])); //Invalid situation -> d2.3
print("g3", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Lowest, 300, null), [CapTrigger.General,300])); //Invalid situation -> b3.3
print("g4", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Lowest, 300, 200), [CapTrigger.Row,200]));
print("g5", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Lowest, 300, 300), [CapTrigger.General,300]));
print("g6", assertEqual(getTrueCapAsTestResult(GeneralCapIsEnabled, RowCapIsEnabled, Presidence.Lowest, 300, 400), [CapTrigger.General,300]));
} }
test_GetTrueCaps_ReturnsExpectedValue(); //Setup our scenarios and expected values
const useCases = getUseCases_where_only_a_GeneralCap_can_be_triggered();
const expectedOutcomes = getExpectedOutcomes_where_only_a_GeneralCap_can_be_triggered();
const verboseLevel = 0;
//const testResults = executeTests(useCases, expectedOutcomes, verboseLevel);
test_GetTrueCaps_ReturnsExpectedValues();
/* /*
@ -1379,9 +1487,8 @@ test_GetTrueCaps_ReturnsExpectedValue();
[ ] Define all expectedOutcomes (write code to write the code?) [ ] Define all expectedOutcomes (write code to write the code?)
[ ] Define all useCases (write code to write the code?) [ ] Define all useCases (write code to write the code?)
[x] test_GetTrueCaps_ReturnsExpectedValue passes all tests [x] test_GetTrueCaps_ReturnsExpectedValue passes all tests
[ ] Code function getBid(tieBid, trueCap, myBid, adjustedBid) [x] Code function getTrueCaps(getTrueCap(isGeneralCapEnabled, isRowCapIsEnabled, presidenceValue, generalCapValue, rowCapValue) Returns {trigger. value}
Returns [capWasTriggered, adjustedBid] [ ] Code function getBid(tieBid, trueCap, myBid, adjustedBid) Returns [capWasTriggered, adjustedBid]
*/ */

Loading…
Cancel
Save