1 /* Copyright (c) 2000-2003, jMock.org. See bundled LICENSE.txt */
2 package org.jmock.matcher;
3
4 import junit.framework.AssertionFailedError;
5 import junit.framework.TestCase;
6 import org.jmock.dynamic.Invocation;
7
8 public class CallOnceMatcherTest extends TestCase {
9 private Invocation emptyInvocation =
10 new Invocation("example", new Class[0], Void.class, new Object[0]);
11 private CallOnceMatcher matcher = new CallOnceMatcher();
12
13 public void testWillMatchIfNotYetInvoked() {
14 assertTrue("Should match", matcher.matches(emptyInvocation));
15 }
16
17 public void testVerifyFailsIfNotYetInvoked() {
18 try {
19 matcher.verify();
20 } catch (AssertionFailedError expected) {
21 return;
22 }
23 fail("Should have thrown exception");
24 }
25
26 public void testWillNotMatchAfterInvocation() {
27 matcher.invoked(emptyInvocation);
28 assertFalse("Should not match", matcher.matches(emptyInvocation));
29 }
30
31 public void testVerifyPassesAfterInvocation() {
32 matcher.invoked(emptyInvocation);
33 matcher.verify();
34 }
35
36 }
This page was automatically generated by Maven