Package org.jmock

Examples of org.jmock.Constraint


    public ConstraintsTest(String test) {
        super(test);
    }

    public void testIsNull() {
        Constraint p = new IsNull();

        assertTrue(p.eval(null));
        assertTrue(!p.eval(new Object()));
    }
View Full Code Here


    }

    public void testIsSame() {
        Object o1 = new Object();
        Object o2 = new Object();
        Constraint p = new IsSame(o1);

        assertTrue(p.eval(o1));
        assertTrue(!p.eval(o2));
    }
View Full Code Here

    }

    public void testIsEqual() {
        Integer i1 = new Integer(1);
        Integer i2 = new Integer(2);
        Constraint p = new IsEqual(i1);

        assertTrue(p.eval(i1));
        assertTrue(p.eval(new Integer(1)));
        assertTrue(!p.eval(i2));
    }
View Full Code Here

        String[] s1 = new String[]{"a", "b"};
        String[] s2 = new String[]{"a", "b"};
        String[] s3 = new String[]{"c", "d"};
        String[] s4 = new String[]{"a", "b", "c", "d"};

        Constraint p = new IsEqual(s1);

        assertTrue("Should equal itself", p.eval(s1));
        assertTrue("Should equal a similar array", p.eval(s2));
        assertTrue("Should not equal a different array", !p.eval(s3));
        assertTrue("Should not equal a different sized array", !p.eval(s4));
    }
View Full Code Here

    }

    public void testIsEqualToStringOnProxyArgument() {
        // Required for error message reporting
        Mock mockDummyInterface = new Mock(DummyInterface.class, "MockName");
        Constraint p = new IsEqual(mockDummyInterface.proxy());

        AssertMo.assertIncludes("Should get resolved toString() with no expectation error", "MockName", p.toString());
    }
View Full Code Here

        assertFalse("Should not be equal - same type different values", new IsEqual("a").equals(new IsEqual("b")));
        assertFalse("Should not be equal - different type", new IsEqual("a").equals("b"));
    }

    public void testIsGreaterThan() {
        Constraint p = new IsGreaterThan(new Integer(1));

        assertTrue(!p.eval(new Integer(0)));
        assertTrue(!p.eval(new Integer(1)));
        assertTrue(p.eval(new Integer(2)));
    }
View Full Code Here

        assertTrue(!p.eval(new Integer(1)));
        assertTrue(p.eval(new Integer(2)));
    }

    public void testIsLessThan() {
        Constraint p = new IsLessThan(new Integer(1));

        assertTrue(p.eval(new Integer(0)));
        assertTrue(!p.eval(new Integer(1)));
        assertTrue(!p.eval(new Integer(2)));
    }
View Full Code Here

        assertTrue(!p.eval(new Integer(1)));
        assertTrue(!p.eval(new Integer(2)));
    }

    public void testIsAnything() {
        Constraint p = new IsAnything();
        assertTrue(p.eval(null));
        assertTrue(p.eval(new Object()));
    }
View Full Code Here

        assertTrue(p.eval(null));
        assertTrue(p.eval(new Object()));
    }

    public void testIsInstanceOf() {
        Constraint p = new IsInstanceOf(Number.class);
        assertTrue(p.eval(new Integer(1)));
        assertTrue(p.eval(new Double(1.0)));
        assertTrue(!p.eval("a string"));
        assertTrue(!p.eval(null));
    }
View Full Code Here

        assertTrue(!p.eval("a string"));
        assertTrue(!p.eval(null));
    }

    public void testIsNot() {
        Constraint p = new IsNot(new True());
        assertTrue(!p.eval(null));
        assertTrue(!p.eval(new Object()));
    }
View Full Code Here

TOP

Related Classes of org.jmock.Constraint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.