105 lines
3.5 KiB
Dart
105 lines
3.5 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:uto_manager/domain/entities/echelon.dart';
|
|
|
|
void main() {
|
|
group('Echelon', () {
|
|
group('displayName', () {
|
|
test('returns correct display name for each echelon', () {
|
|
expect(Echelon.brigade.displayName, equals('Brigade'));
|
|
expect(Echelon.battalion.displayName, equals('Battalion'));
|
|
expect(Echelon.company.displayName, equals('Company'));
|
|
expect(Echelon.platoon.displayName, equals('Platoon'));
|
|
expect(Echelon.section.displayName, equals('Section'));
|
|
expect(Echelon.squad.displayName, equals('Squad'));
|
|
expect(Echelon.team.displayName, equals('Team'));
|
|
});
|
|
});
|
|
|
|
group('level', () {
|
|
test('brigade has the lowest level number (highest echelon)', () {
|
|
expect(Echelon.brigade.level, equals(1));
|
|
});
|
|
|
|
test('team has the highest level number (lowest echelon)', () {
|
|
expect(Echelon.team.level, equals(7));
|
|
});
|
|
|
|
test('levels are strictly ordered from brigade to team', () {
|
|
final echelons = [
|
|
Echelon.brigade,
|
|
Echelon.battalion,
|
|
Echelon.company,
|
|
Echelon.platoon,
|
|
Echelon.section,
|
|
Echelon.squad,
|
|
Echelon.team,
|
|
];
|
|
for (var i = 0; i < echelons.length - 1; i++) {
|
|
expect(
|
|
echelons[i].level,
|
|
lessThan(echelons[i + 1].level),
|
|
reason: '${echelons[i].displayName} should have lower level than '
|
|
'${echelons[i + 1].displayName}',
|
|
);
|
|
}
|
|
});
|
|
});
|
|
|
|
group('isValidParent', () {
|
|
test('battalion is a valid parent for company', () {
|
|
expect(Echelon.company.isValidParent(Echelon.battalion), isTrue);
|
|
});
|
|
|
|
test('brigade is a valid parent for battalion', () {
|
|
expect(Echelon.battalion.isValidParent(Echelon.brigade), isTrue);
|
|
});
|
|
|
|
test('company is a valid parent for platoon', () {
|
|
expect(Echelon.platoon.isValidParent(Echelon.company), isTrue);
|
|
});
|
|
|
|
test('platoon is a valid parent for section', () {
|
|
expect(Echelon.section.isValidParent(Echelon.platoon), isTrue);
|
|
});
|
|
|
|
test('section is a valid parent for squad', () {
|
|
expect(Echelon.squad.isValidParent(Echelon.section), isTrue);
|
|
});
|
|
|
|
test('squad is a valid parent for team', () {
|
|
expect(Echelon.team.isValidParent(Echelon.squad), isTrue);
|
|
});
|
|
|
|
test('brigade is NOT a valid parent for company (skips battalion)', () {
|
|
expect(Echelon.company.isValidParent(Echelon.brigade), isFalse);
|
|
});
|
|
|
|
test('brigade is NOT a valid parent for platoon', () {
|
|
expect(Echelon.platoon.isValidParent(Echelon.brigade), isFalse);
|
|
});
|
|
|
|
test('same echelon is NOT a valid parent', () {
|
|
expect(Echelon.platoon.isValidParent(Echelon.platoon), isFalse);
|
|
});
|
|
|
|
test('child echelon is NOT a valid parent', () {
|
|
expect(Echelon.brigade.isValidParent(Echelon.battalion), isFalse);
|
|
});
|
|
});
|
|
|
|
group('isValidChild', () {
|
|
test('company is a valid child of battalion', () {
|
|
expect(Echelon.battalion.isValidChild(Echelon.company), isTrue);
|
|
});
|
|
|
|
test('battalion is a valid child of brigade', () {
|
|
expect(Echelon.brigade.isValidChild(Echelon.battalion), isTrue);
|
|
});
|
|
|
|
test('platoon is NOT a valid child of brigade', () {
|
|
expect(Echelon.brigade.isValidChild(Echelon.platoon), isFalse);
|
|
});
|
|
});
|
|
});
|
|
}
|