|
|
|
@ -1,10 +1,9 @@
|
|
|
|
|
import 'package:flame/components.dart';
|
|
|
|
|
import 'package:flame_forge2d/flame_forge2d.dart';
|
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
|
import 'package:mocktail/mocktail.dart';
|
|
|
|
|
import 'package:pinball/game/game.dart';
|
|
|
|
|
|
|
|
|
|
class MockHasScore extends Mock with ScorePoints {}
|
|
|
|
|
class MockScorePoints extends Mock with ScorePoints {}
|
|
|
|
|
|
|
|
|
|
class MockBall extends Mock implements Ball {}
|
|
|
|
|
|
|
|
|
@ -14,18 +13,24 @@ class MockPinballGame extends Mock implements PinballGame {}
|
|
|
|
|
|
|
|
|
|
class FakeContact extends Fake implements Contact {}
|
|
|
|
|
|
|
|
|
|
class FakeGameEvent extends Fake implements GameEvent {}
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
group('BallScorePointsCallback', () {
|
|
|
|
|
late MockPinballGame game;
|
|
|
|
|
late MockGameBloc bloc;
|
|
|
|
|
late MockBall ball;
|
|
|
|
|
late MockHasScore hasScore;
|
|
|
|
|
late MockScorePoints scorePoints;
|
|
|
|
|
|
|
|
|
|
setUp(() {
|
|
|
|
|
game = MockPinballGame();
|
|
|
|
|
bloc = MockGameBloc();
|
|
|
|
|
ball = MockBall();
|
|
|
|
|
hasScore = MockHasScore();
|
|
|
|
|
scorePoints = MockScorePoints();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
setUpAll(() {
|
|
|
|
|
registerFallbackValue(FakeGameEvent());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
group('begin', () {
|
|
|
|
@ -36,11 +41,11 @@ void main() {
|
|
|
|
|
|
|
|
|
|
when<PinballGame>(() => ball.gameRef).thenReturn(game);
|
|
|
|
|
when<GameBloc>(game.read).thenReturn(bloc);
|
|
|
|
|
when<int>(() => hasScore.points).thenReturn(points);
|
|
|
|
|
when<int>(() => scorePoints.points).thenReturn(points);
|
|
|
|
|
|
|
|
|
|
BallScorePointsCallback().begin(
|
|
|
|
|
ball,
|
|
|
|
|
hasScore,
|
|
|
|
|
scorePoints,
|
|
|
|
|
FakeContact(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
@ -52,8 +57,16 @@ void main() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
group('end', () {
|
|
|
|
|
test('does nothing', () {
|
|
|
|
|
// TODO(alestiago): Write test.
|
|
|
|
|
test("doesn't add events to GameBloc", () {
|
|
|
|
|
BallScorePointsCallback().end(
|
|
|
|
|
ball,
|
|
|
|
|
scorePoints,
|
|
|
|
|
FakeContact(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
verifyNever(
|
|
|
|
|
() => bloc.add(any()),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|