platform/test/common.dart

54 lines
1.1 KiB
Dart
Raw Normal View History

2016-06-27 00:20:42 +00:00
library angel_framework.test.common;
2016-12-10 14:05:40 +00:00
import 'package:angel_framework/angel_framework.dart';
import 'package:matcher/matcher.dart';
2017-02-13 00:38:33 +00:00
class Todo extends Model {
2016-06-27 00:20:42 +00:00
String text;
String over;
Todo({String this.text, String this.over});
}
2016-12-10 14:05:40 +00:00
2017-01-28 03:47:00 +00:00
class BookService extends Service {
@override
index([params]) async {
print('Book params: $params');
2017-09-22 14:03:23 +00:00
2017-01-28 03:47:00 +00:00
return [
{'foo': 'bar'}
];
}
}
2016-12-10 14:05:40 +00:00
incrementTodoTimes(e) {
IncrementService.TIMES++;
}
@Hooks(before: const [incrementTodoTimes])
class IncrementService extends Service {
static int TIMES = 0;
@override
@Hooks(after: const [incrementTodoTimes])
index([params]) async => [];
}
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) {
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;
}