Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #172 from 2rabs/rt/add-test-schedule-repository
Browse files Browse the repository at this point in the history
💚 TestScheduleRepository を追加
  • Loading branch information
tatsutakein authored Apr 20, 2023
2 parents 9afcea1 + eb8bad5 commit f0b18a2
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 19 deletions.
6 changes: 1 addition & 5 deletions packages/core/testing/lib/core_testing.dart
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';
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();
}
}
10 changes: 8 additions & 2 deletions packages/core/testing/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_test:
sdk: flutter
core_common:
path: ../common
core_data:
path: ../data
core_domain:
path: ../domain
core_model:
path: ../model

dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0

# For information on the generic Dart part of this file, see the
Expand Down
12 changes: 0 additions & 12 deletions packages/core/testing/test/core_testing_test.dart

This file was deleted.

0 comments on commit f0b18a2

Please sign in to comment.