Last active
February 17, 2025 05:40
-
-
Save yamnikov-oleg/aaa56dbb32a77e3b3a4acc84e455abfc to your computer and use it in GitHub Desktop.
Flutter: Тесты репозитория
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
// ЗАДАНИЕ: | |
// Завершите реализацию класса LocalOrderRepository согласно документации | |
// его интерфейса. | |
// Покройте реализацию юнит-тестами. | |
import 'package:flutter_test/flutter_test.dart'; | |
import 'package:equatable/equatable.dart'; | |
/// Заказ. | |
class Order extends Equatable { | |
Order({ | |
required this.id, | |
required this.clientName, | |
required this.address, | |
}); | |
final int id; | |
final String clientName; | |
final String address; | |
@override | |
List<Object> get props => [id, clientName, address]; | |
} | |
abstract interface class OrderRepository { | |
/// Возвращает список заказов, начиная с индекса offset (по-умолчанию - с индекса 0). | |
/// Возвращает максимум limit заказов (по-умолчанию ограничения нет). | |
Future<List<Order>> getList({int? offset, int? limit}); | |
} | |
/// Реализация OrderRepository, которая хранит список заказов в памяти. | |
class LocalOrderRepository implements OrderRepository { | |
LocalOrderRepository(List<Order> orders) : _orders = orders; | |
final List<Order> _orders; | |
@override | |
Future<List<Order>> getList({int? offset, int? limit}) { | |
throw UnimplementedError(); | |
} | |
} | |
void main() { | |
// Место для тестов | |
test("...", () {}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment