/* File: model-test-case.js Class: CounterTestCase //framework 1) Code tagged with the tag //framework requires a minor edit or no edit (comment by tag will inform) 2) The expression "extends superClass" below is also part of the framework support (no edit required) */ //framework -- test case name addTestCase("CounterTestCase"); class CounterTestCase extends TestCase { //ivars: unit //----------------- //Unit Test Support getUnitName() { //framework -- model type (class) return 'Counter'; } //----------------- //Setup beforeEach() { //Called before each test for test setup (if needed) //Construct a unit model for testing (we use ivar "unit") super.beforeEach(); //framework - name of model class here (and using the constructor that is available) this.unit = new Counter(); } //----------------- //Tests testConstruction() { //Initially we expect count to be 0 this.assertEquals(0, this.unit.getCount()); } testIncrement() { const counter = this.unit; counter.increment(); counter.increment(); this.assertEquals(2, counter.getCount()); } testDecrement() { const counter = this.unit; counter.decrement(); counter.decrement(); this.assertEquals(-2, counter.getCount()); } }