Commit 2d8cef4d authored by Totmak's avatar Totmak
Browse files

test

parent fe139ce4
Pipeline #41214 passed with stages
in 8 minutes and 25 seconds
import {allSquares} from "./Board.js"
import {propertyID,propertyArray, squareSelection} from "./Property.js"
import {cornerID, cornerArray} from "./CornerProperty.js"
import {eventID, eventArray} from "./EventProperty.js"
import {pawnID, pawnArray} from "./Pawn.js"
import {player, playerArray} from "./Player.js"
import {shareID, shareArray} from "./Share.js"
import {turnNumber} from "./Basic.js"
export default class UnitTest{
static runUnitTest(){
var t = this.totalNumberOfSquaresIs(32);
t += this.numberOfPropertiesIs(24);
t += this.numberOfCornerIs(4);
t += this.numberOfEventsIs(4);
t += this.turnIs(0);
t += this.numberOfPawnIs(4);
t += this.numberOfPlayersIs(1);
t += this.playerHasMoneyAmountOf(100);
t += this.selectionIsEmpty();
t += this.numberOfShareIs(240);
t += this.nobodyOwnsProperties();
t += this.positionOfPawnIs(1,0,0);
t += this.positionOfPawnIs(2,20,20);
t += this.positionOfPawnIs(3,40,40);
t += this.positionOfPawnIs(4,60,60);
return t == 15;
}
static totalNumberOfSquaresIs(n){
var t = allSquares.length == n;
console.info("Has "+n+" squares:"+t);
return t;
}
static numberOfPropertiesIs(n){
var t = propertyID == propertyArray.length && propertyID == n;
console.info("Has "+n+" properties:"+t);
return t;
}
static numberOfCornerIs(n){
var t = cornerID == cornerArray.length && cornerID == n;
console.info("Has "+n+" corners:"+t);
return t;
}
static numberOfEventsIs(n){
var t = eventID == eventArray.length && eventID == n;
console.info("Has "+n+" events:"+t);
return t;
}
static turnIs(n){
var t = turnNumber == n;
console.info("Turn number is "+n+":"+t);
return t;
}
static numberOfPawnIs(n){
var t = pawnID == pawnArray.length && pawnID == n;
console.info("Has "+n+" pawns:"+t);
return t;
}
static numberOfPlayersIs(n){
var t = playerArray.length == n;
console.info("Number of player is "+n+":"+t);
return t;
}
static playerHasMoneyAmountOf(n){
var t = (player != null) && (player.treasury == n);
console.info("Player has "+n+" money:"+t);
return t;
}
static selectionIsEmpty(n){
var t = squareSelection == null;
console.info("Selection is empty:"+t);
return t;
}
static numberOfShareIs(n){
var t = shareID == shareArray.length && shareID == n;
console.info("Number of share is "+n+":"+t);
return t;
}
static positionOfPawnIs(id, xc, yc){
var p = document.getElementById("pawn"+id);
var t = p.style.left == xc+"px" && p.style.top == yc+"px";
console.info("Coordinate of pawn #"+id+" is "+xc+", "+yc+":"+t);
return t;
}
static nobodyOwnsProperties(){
var t = true;
for(var x of propertyArray){
if (x.owner != null){
t = false;
break;
}
}
console.info("Nobody owns properties:"+t);
return t;
}
}
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