hasancse1991

Bongabdo Flutter Package Unit test

Jan 10th, 2022 (edited)
747
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 2.26 KB | None | 0 0
  1. import '/app/core/bongabdo/bongabdo.dart';
  2. import 'package:test/test.dart';
  3.  
  4. void main() {
  5.   Map<DateTime, String> testCaseMap = Map();
  6.   prepareTestCases(testCaseMap);
  7.  
  8.   final Bongabdo bongabdo = Bongabdo();
  9.  
  10.   testCaseMap.forEach((dateTime, bongabdoDate) {
  11.     test('Bongabdo Unit Test', () {
  12.       bongabdo.set(dateTime: dateTime);
  13.       expect(
  14.         "${bongabdo.day} ${bongabdo.month} ${bongabdo.year} ${bongabdo.season}",
  15.         bongabdoDate,
  16.       );
  17.     });
  18.   });
  19. }
  20.  
  21. void prepareTestCases(Map<DateTime, String> testCaseMap) {
  22.   // Bangladesh / Leap Year / Ordinary day test
  23.   testCaseMap[DateTime(2020, 1, 1)] = '17 8 1426 4';
  24.   testCaseMap[DateTime(2020, 4, 13)] = '30 11 1426 5';
  25.   testCaseMap[DateTime(2020, 4, 14)] = '1 0 1427 0';
  26.   testCaseMap[DateTime(2020, 4, 30)] = '17 0 1427 0';
  27.   testCaseMap[DateTime(2028, 4, 1)] = '18 11 1434 5';
  28.   testCaseMap[DateTime(2028, 4, 13)] = '30 11 1434 5';
  29.   testCaseMap[DateTime(2028, 4, 14)] = '1 0 1435 0';
  30.   testCaseMap[DateTime(2028, 9, 30)] = '15 5 1435 2';
  31.   testCaseMap[DateTime(2028, 12, 1)] = '16 7 1435 3';
  32.   testCaseMap[DateTime(2028, 12, 31)] = '16 8 1435 4';
  33.  
  34.   // Bangladesh / Non-Leap Year / Ordinary day test
  35.   testCaseMap[DateTime(2021, 1, 1)] = '17 8 1427 4';
  36.   testCaseMap[DateTime(2021, 1, 31)] = '17 9 1427 4';
  37.   testCaseMap[DateTime(2021, 2, 18)] = '5 10 1427 5';
  38.   testCaseMap[DateTime(2021, 4, 13)] = '30 11 1427 5';
  39.   testCaseMap[DateTime(2021, 4, 14)] = '1 0 1428 0';
  40.   testCaseMap[DateTime(2100, 3, 14)] = '29 10 1506 5';
  41.   testCaseMap[DateTime(2100, 3, 15)] = '1 11 1506 5';
  42.   testCaseMap[DateTime(2100, 4, 13)] = '30 11 1506 5';
  43.  
  44.   // Bangladesh / Leap Year / Special day test
  45.   testCaseMap[DateTime(2020, 2, 21)] = '8 10 1426 5';
  46.   testCaseMap[DateTime(2020, 3, 26)] = '12 11 1426 5';
  47.   testCaseMap[DateTime(2020, 5, 8)] = '25 0 1427 0';
  48.   testCaseMap[DateTime(2020, 5, 25)] = '11 1 1427 0';
  49.   testCaseMap[DateTime(2020, 12, 16)] = '1 8 1427 4';
  50.  
  51.   // Bangladesh / Non-Leap Year / Special day test
  52.   testCaseMap[DateTime(2021, 2, 21)] = '8 10 1427 5';
  53.   testCaseMap[DateTime(2021, 3, 26)] = '12 11 1427 5';
  54.   testCaseMap[DateTime(2021, 5, 8)] = '25 0 1428 0';
  55.   testCaseMap[DateTime(2021, 5, 25)] = '11 1 1428 0';
  56.   testCaseMap[DateTime(2021, 12, 16)] = '1 8 1428 4';
  57. }
  58.  
Add Comment
Please, Sign In to add comment