1   // Copyright (c) 2003, Chad Woolley, All rights reserved.
2   
3   package org.virtualmock.matcher;
4   
5   import junit.framework.Test;
6   import junit.framework.TestCase;
7   import org.hansel.CoverageDecorator;
8   import org.virtualmock.matcher.MatcherUtils;
9   
10  
11  /***
12   * Tests the MatcherUtils class
13   *
14   * @author Chad Woolley
15   * @version $Revision: 1.1 $
16   */
17  public class MatcherUtilsTest extends TestCase {
18      MatcherUtils matcherUtils = null;
19      Object objectOne = null;
20      Object objectTwo = null;
21  
22      /***
23       * Hansel support
24       *
25       * @return the decorated Test
26       */
27      public static Test suite() {
28          CoverageDecorator cd =
29              new CoverageDecorator(MatcherUtilsTest.class,
30                  new Class[] {MatcherUtils.class});
31          cd.setDisplayStatistics(true);
32  
33          return cd;
34      }
35  
36      /***
37       * Set up the test
38       *
39       * @throws Exception any exception thrown during setup.
40       */
41      public void setUp() throws Exception {
42          super.setUp();
43          matcherUtils = new MatcherUtils();
44      }
45  
46      /***
47       * Test that the areBothNullOrNotNull method returns false if  the first
48       * argument is not null and the second is.
49       */
50      public void testReturnsFalseIfFirstIsNotNullAndSecondIsNull() {
51          objectOne = new Object();
52          assertFalse(matcherUtils.areBothNull(objectOne, objectTwo));
53          assertFalse(matcherUtils.areBothNotNull(objectOne, objectTwo));
54      }
55  
56      /***
57       * Test that the areBothNullOrNotNull method returns false if  the first
58       * argument is null and the second is not.
59       */
60      public void testReturnsFalseIfFirstIsNullAndSecondIsNotNull() {
61          objectTwo = new Object();
62          assertFalse(matcherUtils.areBothNull(objectOne, objectTwo));
63          assertFalse(matcherUtils.areBothNotNull(objectOne, objectTwo));
64      }
65  
66      /***
67       * Test that the areBothNullOrNotNull method returns true if both are not
68       * null.
69       */
70      public void testReturnsTrueIfBothAreNotNull() {
71          objectOne = new Object();
72          objectTwo = new Object();
73          assertTrue(matcherUtils.areBothNotNull(objectOne, objectTwo));
74      }
75  
76      /***
77       * Test that the areBothNullOrNotNull method returns true if both are null.
78       */
79      public void testReturnsTrueIfBothAreNull() {
80          assertTrue(matcherUtils.areBothNull(objectOne, objectTwo));
81      }
82  }