File tree Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -703,17 +703,28 @@ _InOrderVerification get verifyInOrder {
703
703
};
704
704
}
705
705
706
+ void _throwMockArgumentError (method) =>
707
+ throw new ArgumentError ('$method must only be given a Mock object' );
708
+
706
709
void verifyNoMoreInteractions (var mock) {
707
- var unverified = mock._realCalls.where ((inv) => ! inv.verified).toList ();
708
- if (unverified.isNotEmpty) {
709
- fail ("No more calls expected, but following found: " + unverified.join ());
710
+ if (mock is Mock ) {
711
+ var unverified = mock._realCalls.where ((inv) => ! inv.verified).toList ();
712
+ if (unverified.isNotEmpty) {
713
+ fail ("No more calls expected, but following found: " + unverified.join ());
714
+ }
715
+ } else {
716
+ _throwMockArgumentError ('verifyNoMoreInteractions' );
710
717
}
711
718
}
712
719
713
720
void verifyZeroInteractions (var mock) {
714
- if (mock._realCalls.isNotEmpty) {
715
- fail ("No interaction expected, but following found: " +
716
- mock._realCalls.join ());
721
+ if (mock is Mock ) {
722
+ if (mock._realCalls.isNotEmpty) {
723
+ fail ("No interaction expected, but following found: " +
724
+ mock._realCalls.join ());
725
+ }
726
+ } else {
727
+ _throwMockArgumentError ('verifyZeroInteractions' );
717
728
}
718
729
}
719
730
Original file line number Diff line number Diff line change @@ -936,6 +936,11 @@ void main() {
936
936
verify (mock.methodWithoutArgs ());
937
937
verifyNoMoreInteractions (mock);
938
938
});
939
+
940
+ test ("throws if given a real object" , () {
941
+ expect (
942
+ () => verifyNoMoreInteractions (new RealClass ()), throwsArgumentError);
943
+ });
939
944
});
940
945
941
946
group ("verifyInOrder()" , () {
You can’t perform that action at this time.
0 commit comments