platform/test/common.dart
2018-07-09 12:50:20 -04:00

53 lines
1.1 KiB
Dart

library angel_framework.test.common;
import 'package:angel_framework/angel_framework.dart';
import 'package:matcher/matcher.dart';
class Todo extends Model {
String text;
String over;
Todo({String this.text, String this.over});
}
class BookService extends Service {
@override
index([params]) async {
print('Book params: $params');
return [
{'foo': 'bar'}
];
}
}
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
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;
}