66 lines
1.9 KiB
Dart
66 lines
1.9 KiB
Dart
import 'package:test/test.dart';
|
|
import 'package:tdd_katas/mars_rover.dart';
|
|
|
|
void main() {
|
|
group('Mars Rover:', () {
|
|
test('rover reports initial position and direction', () {
|
|
final rover = Rover(x: 0, y: 0, direction: 'N');
|
|
|
|
expect(rover.x, equals(0));
|
|
expect(rover.y, equals(0));
|
|
expect(rover.direction, equals('N'));
|
|
});
|
|
|
|
group('Turning Left:', () {
|
|
test('from North faces West', () {
|
|
final rover = Rover(x: 0, y: 0, direction: 'N');
|
|
rover.turnLeft();
|
|
expect(rover.direction, equals('W'));
|
|
});
|
|
|
|
test('from West faces South', () {
|
|
final rover = Rover(x: 0, y: 0, direction: 'W');
|
|
rover.turnLeft();
|
|
expect(rover.direction, equals('S'));
|
|
});
|
|
|
|
test('from South faces East', () {
|
|
final rover = Rover(x: 0, y: 0, direction: 'S');
|
|
rover.turnLeft();
|
|
expect(rover.direction, equals('E'));
|
|
});
|
|
|
|
test('from East faces North', () {
|
|
final rover = Rover(x: 0, y: 0, direction: 'E');
|
|
rover.turnLeft();
|
|
expect(rover.direction, equals('N'));
|
|
});
|
|
});
|
|
|
|
group('Turning Right:', () {
|
|
test('from North faces East', () {
|
|
final rover = Rover(x: 0, y: 0, direction: 'N');
|
|
rover.turnRight();
|
|
expect(rover.direction, equals('E'));
|
|
});
|
|
|
|
test('from East faces South', () {
|
|
final rover = Rover(x: 0, y: 0, direction: 'E');
|
|
rover.turnRight();
|
|
expect(rover.direction, equals('S'));
|
|
});
|
|
|
|
test('from South faces West', () {
|
|
final rover = Rover(x: 0, y: 0, direction: 'S');
|
|
rover.turnRight();
|
|
expect(rover.direction, equals('W'));
|
|
});
|
|
|
|
test('from West faces North', () {
|
|
final rover = Rover(x: 0, y: 0, direction: 'W');
|
|
rover.turnRight();
|
|
expect(rover.direction, equals('N'));
|
|
});
|
|
});
|
|
});
|
|
}
|