import 'package:angel3_reactivex/angel3_reactivex.dart'; import 'package:test/test.dart'; void main() { group('StreamNotification', () { test('hashCode', () { final value1 = 1; final value2 = 2; final st1 = StackTrace.current; final st2 = StackTrace.current; expect( StreamNotification.data(value1).hashCode, StreamNotification.data(value1).hashCode, ); expect( StreamNotification.data(value1).hashCode, StreamNotification.data(value1).hashCode, ); expect( StreamNotification.data(value1).hashCode, isNot(StreamNotification.data(value2).hashCode), ); expect( StreamNotification.done().hashCode, StreamNotification.done().hashCode, ); expect( StreamNotification.done().hashCode, StreamNotification.done().hashCode, ); expect( StreamNotification.error(value1, st1).hashCode, StreamNotification.error(value1, st1).hashCode, ); expect( StreamNotification.error(value1, st1).hashCode, isNot(StreamNotification.error(value2, st1).hashCode), ); expect( StreamNotification.error(value1, st1).hashCode, isNot(StreamNotification.error(value1, st2).hashCode), ); expect( StreamNotification.error(value1, st1).hashCode, isNot(StreamNotification.error(value2, st2).hashCode), ); expect( StreamNotification.data(value1).hashCode, isNot(StreamNotification.done().hashCode), ); expect( StreamNotification.data(value1).hashCode, isNot(StreamNotification.error(value1, st1).hashCode), ); expect( StreamNotification.done().hashCode, isNot(StreamNotification.error(value1, st1).hashCode), ); }); test('==', () { final value1 = 1; final value2 = 2; final st1 = StackTrace.current; final st2 = StackTrace.current; expect( StreamNotification.data(value1), StreamNotification.data(value1), ); expect( StreamNotification.data(value1), isNot(StreamNotification.data(value1)), ); expect( StreamNotification.data(value1), isNot(StreamNotification.data(value2)), ); expect( StreamNotification.done(), StreamNotification.done(), ); expect( const StreamNotification.done(), StreamNotification.done(), ); expect( StreamNotification.done(), StreamNotification.done(), ); expect( StreamNotification.error(value1, st1), StreamNotification.error(value1, st1), ); expect( StreamNotification.error(value1, st1), isNot(StreamNotification.error(value2, st1)), ); expect( StreamNotification.error(value1, st1), isNot(StreamNotification.error(value1, st2)), ); expect( StreamNotification.error(value1, st1), isNot(StreamNotification.error(value2, st2)), ); expect( StreamNotification.data(value1), isNot(StreamNotification.done()), ); expect( StreamNotification.data(value1), isNot(StreamNotification.error(value1, st1)), ); expect( StreamNotification.done(), isNot(StreamNotification.error(value1, st1)), ); }); test('toString', () { expect( StreamNotification.data(1).toString(), 'DataNotification{value: 1}', ); expect( StreamNotification.done().toString(), 'DoneNotification{}', ); expect( StreamNotification.error(2, StackTrace.empty).toString(), 'ErrorNotification{error: 2, stackTrace: }', ); }); test('requireData', () { expect( StreamNotification.data(1).requireDataValue, 1, ); expect( () => StreamNotification.done().requireDataValue, throwsA(isA()), ); expect( () => StreamNotification.error(2, StackTrace.empty).requireDataValue, throwsA(isA()), ); }); test('errorAndStackTraceOrNull', () { expect( StreamNotification.data(1).errorAndStackTraceOrNull, isNull, ); expect( StreamNotification.done().errorAndStackTraceOrNull, isNull, ); expect( StreamNotification.error(2, StackTrace.empty) .errorAndStackTraceOrNull, ErrorAndStackTrace(2, StackTrace.empty), ); }); test('isOnData', () { expect( StreamNotification.data(1).isData, isTrue, ); expect( StreamNotification.done().isData, isFalse, ); expect( StreamNotification.error(2, StackTrace.empty).isData, isFalse, ); }); test('isOnDone', () { expect( StreamNotification.data(1).isDone, isFalse, ); expect( StreamNotification.done().isDone, isTrue, ); expect( StreamNotification.error(2, StackTrace.empty).isDone, isFalse, ); }); test('isOnError', () { expect( StreamNotification.data(1).isError, isFalse, ); expect( StreamNotification.done().isError, isFalse, ); expect( StreamNotification.error(2, StackTrace.empty).isError, isTrue, ); }); }); }