From d2d9c2a320ab58bebc94ca6ce8d8d7cd02640af0 Mon Sep 17 00:00:00 2001 From: murali-shris Date: Tue, 27 Sep 2022 17:04:00 +0530 Subject: [PATCH] fix: add unit test --- at_commons/test/at_exception_stack_test.dart | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 at_commons/test/at_exception_stack_test.dart diff --git a/at_commons/test/at_exception_stack_test.dart b/at_commons/test/at_exception_stack_test.dart new file mode 100644 index 00000000..ccb35072 --- /dev/null +++ b/at_commons/test/at_exception_stack_test.dart @@ -0,0 +1,32 @@ +import 'package:at_commons/at_commons.dart'; +import 'package:test/test.dart'; + +void main() { + group('A group of tests for exception stack', () { + test('chained exception list size greater than zero - check trace message', + () { + final atChainedException = AtChainedException( + Intent.syncData, ExceptionScenario.invalidKeyFormed, 'sync issue'); + final exceptionStack = AtExceptionStack(); + exceptionStack.add(atChainedException); + expect(exceptionStack.getTraceMessage(), isNotEmpty); + expect(exceptionStack.getTraceMessage(), + startsWith('Failed to syncData caused by')); + }); + + test('chained exception list size is zero', () { + final exceptionStack = AtExceptionStack(); + expect(exceptionStack.getTraceMessage(), isEmpty); + }); + + test('check intent message', () { + final atChainedException = AtChainedException( + Intent.syncData, ExceptionScenario.invalidKeyFormed, 'sync issue'); + final exceptionStack = AtExceptionStack(); + exceptionStack.add(atChainedException); + expect(exceptionStack.getIntentMessage(Intent.syncData), isNotEmpty); + expect(exceptionStack.getIntentMessage(Intent.syncData), + equals('Failed to syncData')); + }); + }); +}