Removed references to super which prevent use Mock as mixin.
https://github.com/fibulwinter/dart-mockito/issues/2
diff --git a/lib/mockito.dart b/lib/mockito.dart
index 7a8ad0f..172babe 100644
--- a/lib/mockito.dart
+++ b/lib/mockito.dart
@@ -37,10 +37,10 @@
}
}
- int get hashCode => _givenHashCode==null ? super.hashCode : _givenHashCode;
+ int get hashCode => _givenHashCode==null ? 0 : _givenHashCode;
bool operator ==(other) => (_givenHashCode!=null && other is Mock)
- ? _givenHashCode==other._givenHashCode : super==other;
+ ? _givenHashCode==other._givenHashCode : identical(this, other);
String toString() => _givenName != null ? _givenName : runtimeType.toString();
}
diff --git a/pubspec.yaml b/pubspec.yaml
index df0b7f3..c5845a4 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,12 +1,11 @@
name: mockito
-version: 0.8.1
+version: 0.8.2
author: Dmitriy Fibulwinter <fibulwinter@gmail.com>
+description: A mock framework inspired by Mockito.
homepage: https://github.com/fibulwinter/dart-mockito
-description: >
- A mock framework inspired by Mockito.
-dependencies:
- matcher: ">=0.10.0 <1.0.0"
-dev_dependencies:
- unittest: ">=0.11.0 <1.0.0"
environment:
- sdk: ">=1.0.0 <2.0.0"
\ No newline at end of file
+ sdk: '>=1.0.0 <2.0.0'
+dependencies:
+ matcher: '>=0.10.0 <1.0.0'
+dev_dependencies:
+ unittest: '>=0.11.0 <1.0.0'
diff --git a/test/mockitoSpec.dart b/test/mockitoSpec.dart
index 8c2bc83..2ea3728 100644
--- a/test/mockitoSpec.dart
+++ b/test/mockitoSpec.dart
@@ -12,6 +12,19 @@
}
}
+abstract class Foo {
+ String bar();
+}
+
+abstract class AbstractFoo implements Foo {
+ String bar() => baz();
+
+ String baz();
+}
+
+class MockFoo extends AbstractFoo with Mock {
+}
+
class MockedClass extends Mock implements RealClass{}
expectFail(String expectedMessage, expectedToFail()){
@@ -36,6 +49,14 @@
mock = new MockedClass();
});
+ group("mixin support", (){
+ test("should work", (){
+ var foo = new MockFoo();
+ when(foo.baz()).thenReturn('baz');
+ expect(foo.bar(), 'baz');
+ });
+ });
+
group("when()", (){
test("should mock method without args", (){
when(mock.methodWithoutArgs()).thenReturn("A");