2016-06-27 00:20:42 +00:00
|
|
|
library angel_framework.test.common;
|
|
|
|
|
2021-05-14 10:34:09 +00:00
|
|
|
import 'package:angel3_framework/angel3_framework.dart';
|
2018-07-09 14:28:32 +00:00
|
|
|
import 'package:matcher/matcher.dart';
|
2016-09-15 19:53:01 +00:00
|
|
|
|
2017-02-13 00:38:33 +00:00
|
|
|
class Todo extends Model {
|
2021-03-20 08:11:18 +00:00
|
|
|
String? text;
|
|
|
|
String? over;
|
2016-06-27 00:20:42 +00:00
|
|
|
|
2019-05-31 03:49:00 +00:00
|
|
|
Todo({this.text, this.over});
|
2018-08-21 18:50:43 +00:00
|
|
|
|
|
|
|
Map<String, dynamic> toJson() {
|
|
|
|
return {
|
|
|
|
'text': text,
|
|
|
|
'over': over,
|
|
|
|
};
|
|
|
|
}
|
2016-06-27 00:20:42 +00:00
|
|
|
}
|
2016-12-10 14:05:40 +00:00
|
|
|
|
2017-01-28 03:47:00 +00:00
|
|
|
class BookService extends Service {
|
|
|
|
@override
|
2021-07-08 02:42:40 +00:00
|
|
|
Future<List> index([params]) async {
|
2017-01-28 03:47:00 +00:00
|
|
|
print('Book params: $params');
|
2017-09-22 14:03:23 +00:00
|
|
|
|
2017-01-28 03:47:00 +00:00
|
|
|
return [
|
|
|
|
{'foo': 'bar'}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-08 02:42:40 +00:00
|
|
|
void incrementTodoTimes(e) {
|
2016-12-10 14:05:40 +00:00
|
|
|
IncrementService.TIMES++;
|
|
|
|
}
|
|
|
|
|
2019-05-02 22:48:31 +00:00
|
|
|
@Hooks(before: [incrementTodoTimes])
|
2016-12-10 14:05:40 +00:00
|
|
|
class IncrementService extends Service {
|
|
|
|
static int TIMES = 0;
|
|
|
|
|
|
|
|
@override
|
2019-05-02 22:48:31 +00:00
|
|
|
@Hooks(after: [incrementTodoTimes])
|
2021-07-08 02:42:40 +00:00
|
|
|
Future<List> index([params]) async => [];
|
2016-12-10 14:05:40 +00:00
|
|
|
}
|
2018-07-09 14:28:32 +00:00
|
|
|
|
|
|
|
class IsInstanceOf<T> implements Matcher {
|
|
|
|
const IsInstanceOf();
|
|
|
|
|
|
|
|
@override
|
2018-07-09 16:50:20 +00:00
|
|
|
Description describeMismatch(
|
|
|
|
item, Description mismatchDescription, Map matchState, bool verbose) {
|
2018-07-09 14:28:32 +00:00
|
|
|
return mismatchDescription.add('$item is not an instance of $T');
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Description describe(Description description) {
|
|
|
|
return description.add('is an instance of $T');
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
bool matches(item, Map matchState) => item is T;
|
|
|
|
}
|