MeteringCommunicationBloc equality tests

This commit is contained in:
Vadim 2023-06-15 23:28:39 +02:00
parent 801ddd9589
commit 33274ad1f6
3 changed files with 89 additions and 0 deletions

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);
});
},
);
}