diff --git a/lib/service/simulation_service.dart b/lib/service/simulation_service.dart index 8e0c14f..9d5a95b 100644 --- a/lib/service/simulation_service.dart +++ b/lib/service/simulation_service.dart @@ -18,7 +18,7 @@ class SimulationService { } void reset() { - _sim.reset(); + _sim.clearMap(); } void addRandomPattern() { diff --git a/lib/src/Simulation.dart b/lib/src/Simulation.dart index 6a5e3bd..92acd1a 100644 --- a/lib/src/Simulation.dart +++ b/lib/src/Simulation.dart @@ -30,12 +30,12 @@ class Simulation { } Simulation(int w, int h) : this.map = new Grid(w, h) { - this.map = reset(); + this.map = clearMap(); } Simulation.fromGrid(Grid map) : this.map = map; - Grid reset([Grid map]) { + Grid clearMap(Grid map) { map ??= this.map; // dirty = true; // map.setAll(0, List.filled(map.length, false)); diff --git a/test/simulation_test.dart b/test/simulation_test.dart index 4dc7f5f..07a1d29 100644 --- a/test/simulation_test.dart +++ b/test/simulation_test.dart @@ -1,9 +1,9 @@ import 'dart:math'; + import 'package:mockito/mockito.dart'; import 'package:rules_of_living/src/Grid.dart'; -import 'package:test/test.dart'; - import 'package:rules_of_living/src/Simulation.dart'; +import 'package:test/test.dart'; class MockGrid extends Mock implements Grid {} @@ -25,20 +25,20 @@ void main() { var oldMap = sut.map; sut.gridSize = Point(10, 10); expect(sut.map, isNot(same(oldMap))); - }); + }, tags: "nobrowser"); }); group("resetMap", () { test("sets the internal map filled with 'false' ", () { sut.map.set(1, 1, true); - sut.reset(); + sut.clearMap(); expect(sut.map, allOf(TypeMatcher(), isNot(contains(true)))); }); test("sets the simulation to need re-rendering", () { sut.dirty = false; - sut.reset(); + sut.clearMap(); expect(sut.dirty, true); }); - }); + }, tags: "nobrowser"); group("save&load", () { test( "saves a copy of the map which does not change when the actual map changes", @@ -49,5 +49,5 @@ void main() { expect(sut.loadSnapshot(), isNot(equals(snapshot))); }); - }); + }, tags: "nobrowser"); }