import 'dart:math'; import 'package:mockito/mockito.dart'; import 'package:rules_of_living/service/configuration_service.dart'; import 'package:rules_of_living/service/engine_service.dart'; import 'package:rules_of_living/service/simulation_service.dart'; import 'package:rules_of_living/src/Engine.dart'; @TestOn('browser') import 'package:test/test.dart'; class MockEngine extends Mock implements Engine {} void main() { ConfigurationService sut; EngineService engineService; SimulationService simService; MockEngine me; setUp(() { me = MockEngine(); engineService = EngineService(); engineService.engine = me; sut = ConfigurationService(engineService, simService); }); group("simulation speed", () { test("speed changes propagate to engine", () { sut.simSpeed = 312; verify(me.stepsPerSecond = 312); }); }); group("grid size", () { test("grid changes are sent to engine", () { sut.setGridSize(x: 512, y: 388); verify(me.gridSize = Point(512, 388)); }); test("grid can be changed solely on x axis", () { when(me.gridSize).thenReturn(Point(100, 100)); sut.setGridSize(x: 555); verify(me.gridSize = Point(555, 100)); }); test("grid can be changed solely on y axis", () { when(me.gridSize).thenReturn(Point(100, 100)); sut.setGridSize(y: 556); verify(me.gridSize = Point(100, 556)); }); }); }