This repository has been archived by the owner on Aug 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from 2rabs/rt/add-test-schedule-repository
💚 TestScheduleRepository を追加
- Loading branch information
Showing
4 changed files
with
39 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
library core_testing; | ||
|
||
/// A Calculator. | ||
class Calculator { | ||
/// Returns [value] plus 1. | ||
int addOne(int value) => value + 1; | ||
} | ||
export 'src/repository/test_schedule_repository.dart'; |
30 changes: 30 additions & 0 deletions
30
packages/core/testing/lib/src/repository/test_schedule_repository.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'package:core_data/core_data.dart'; | ||
import 'package:core_model/core_model.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
/// テスト用のスケジュールリポジトリ | ||
class TestScheduleRepository extends Fake implements ScheduleRepository { | ||
final List<Schedule> _schedules = [ | ||
const Schedule(id: 1, date: '2023-04-15', isFinished: true), | ||
const Schedule(id: 2, date: '2023-04-16', isFinished: false), | ||
const Schedule(id: 3, date: '2023-04-17', isFinished: false), | ||
]; | ||
|
||
@override | ||
Future<Schedule?> fetchRecentSchedule() async { | ||
return _schedules.last; | ||
} | ||
|
||
@override | ||
Future<List<Schedule>> fetchSchedules() async { | ||
return _schedules; | ||
} | ||
|
||
@override | ||
Future<List<Schedule>> fetchUpcomingSchedules() async { | ||
final now = DateTime.now(); | ||
return _schedules | ||
.where((schedule) => DateTime.parse(schedule.date).isAfter(now)) | ||
.toList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.