Compare commits

..

3 commits

Author SHA1 Message Date
Vadim
33274ad1f6 MeteringCommunicationBloc equality tests 2023-06-15 23:29:56 +02:00
Vadim
801ddd9589 fixed running all tests 2023-06-15 23:09:43 +02:00
Vadim
604ee097a6 verify response vibration 2023-06-15 23:05:04 +02:00
4 changed files with 94 additions and 6 deletions

View file

@ -25,20 +25,17 @@ void main() {
late MeteringBloc bloc;
const iso100 = IsoValue(100, StopType.full);
setUpAll(() {
setUp(() {
meteringInteractor = _MockMeteringInteractor();
communicationBloc = _MockMeteringCommunicationBloc();
when<IsoValue>(() => meteringInteractor.iso).thenReturn(iso100);
when<NdValue>(() => meteringInteractor.ndFilter).thenReturn(NdValue.values.first);
when<Film>(() => meteringInteractor.film).thenReturn(Film.values.first);
when(meteringInteractor.quickVibration).thenAnswer((_) async {});
when(meteringInteractor.responseVibration).thenAnswer((_) async {});
when(meteringInteractor.errorVibration).thenAnswer((_) async {});
});
setUp(() {
communicationBloc = _MockMeteringCommunicationBloc();
bloc = MeteringBloc(
meteringInteractor,
communicationBloc,
@ -47,6 +44,7 @@ void main() {
tearDown(() {
bloc.close();
communicationBloc.close();
});
group(
@ -471,6 +469,7 @@ void main() {
verify: (_) {
verify(() => meteringInteractor.film = const Film.other()).called(1);
verifyNever(() => meteringInteractor.iso = const IsoValue(0, StopType.full));
verifyNever(() => meteringInteractor.responseVibration());
},
expect: () => [
isA<MeteringDataState>()

View file

@ -46,6 +46,7 @@ void main() {
bloc.add(const MeteringInProgressEvent(2));
bloc.add(const MeasureEvent());
bloc.add(const MeteringEndedEvent(2));
bloc.add(const MeteringEndedEvent(2));
},
expect: () => [
isA<MeasureState>(),

View file

@ -0,0 +1,44 @@
// ignore_for_file: prefer_const_constructors
import 'package:lightmeter/screens/metering/communication/event_communication_metering.dart';
import 'package:test/test.dart';
void main() {
group(
'`MeteringInProgressEvent`',
() {
final a = MeteringInProgressEvent(1.0);
final b = MeteringInProgressEvent(1.0);
final c = MeteringInProgressEvent(2.0);
test('==', () {
expect(a == b && b == a, true);
expect(a != c && c != a, true);
expect(b != c && c != b, true);
});
test('hashCode', () {
expect(a.hashCode == b.hashCode, true);
expect(a.hashCode != c.hashCode, true);
expect(b.hashCode != c.hashCode, true);
});
},
);
group(
'`MeteringEndedEvent`',
() {
final a = MeteringEndedEvent(1.0);
final b = MeteringEndedEvent(1.0);
final c = MeteringEndedEvent(2.0);
test('==', () {
expect(a == b && b == a, true);
expect(a != c && c != a, true);
expect(b != c && c != b, true);
});
test('hashCode', () {
expect(a.hashCode == b.hashCode, true);
expect(a.hashCode != c.hashCode, true);
expect(b.hashCode != c.hashCode, true);
});
},
);
}

View file

@ -0,0 +1,44 @@
// ignore_for_file: prefer_const_constructors
import 'package:lightmeter/screens/metering/communication/state_communication_metering.dart';
import 'package:test/test.dart';
void main() {
group(
'`MeteringInProgressState`',
() {
final a = MeteringInProgressState(1.0);
final b = MeteringInProgressState(1.0);
final c = MeteringInProgressState(2.0);
test('==', () {
expect(a == b && b == a, true);
expect(a != c && c != a, true);
expect(b != c && c != b, true);
});
test('hashCode', () {
expect(a.hashCode == b.hashCode, true);
expect(a.hashCode != c.hashCode, true);
expect(b.hashCode != c.hashCode, true);
});
},
);
group(
'`MeteringEndedState`',
() {
final a = MeteringEndedState(1.0);
final b = MeteringEndedState(1.0);
final c = MeteringEndedState(2.0);
test('==', () {
expect(a == b && b == a, true);
expect(a != c && c != a, true);
expect(b != c && c != b, true);
});
test('hashCode', () {
expect(a.hashCode == b.hashCode, true);
expect(a.hashCode != c.hashCode, true);
expect(b.hashCode != c.hashCode, true);
});
},
);
}