cellular-automata/test/simulation_test.dart

38 lines
1.1 KiB
Dart
Raw Normal View History

2018-10-19 17:35:09 +00:00
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';
void main() {
Simulation sut;
setUp(() {
sut = Simulation(10, 10);
});
group("gridSize", () {
test(
"returns the width and height of the underlying grid",
() => expect(
sut.gridSize, equals(Point<int>(sut.map.width, sut.map.height))));
test("sets the underlying grid width and height", () {
sut.gridSize = Point(2, 3);
expect(sut.gridSize, equals(Point(2, 3)));
});
test("creates a new underlying grid on resizing", () {
var oldMap = sut.map;
sut.gridSize = Point(10, 10);
expect(sut.map, isNot(oldMap));
});
});
group("reset", () {
test("returns a map filled with 'false' ", () {
expect(sut.reset(), allOf(TypeMatcher<Grid>(), isNot(contains(true))));
});
test("sets the simulation to need re-rendering", () {
sut.reset();
expect(sut.dirty, true);
}, skip: "can not find a way to set dirty to true first yet");
});
}