From: Tim M. <ma...@us...> - 2003-05-18 20:59:44
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/constraint In directory sc8-pr-cvs1:/tmp/cvs-serv25351/core/test/mockobjects/constraint Modified Files: ConstraintsTest.java Log Message: Integration with branch DynamicMockExperiment. If you have problems - you can revert to Version 08. Index: ConstraintsTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/constraint/ConstraintsTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ConstraintsTest.java 12 Nov 2002 17:42:40 -0000 1.1 +++ ConstraintsTest.java 18 May 2003 20:59:40 -0000 1.2 @@ -5,14 +5,16 @@ package test.mockobjects.constraint; import com.mockobjects.constraint.*; -import com.mockobjects.constraint.*; +import com.mockobjects.dynamic.Mock; +import com.mockobjects.util.AssertMo; -import java.util.EventObject; +import test.mockobjects.dynamic.DummyInterface; +import java.util.EventObject; +import junit.framework.*; -public class ConstraintsTest - extends junit.framework.TestCase +public class ConstraintsTest extends TestCase { class True implements Constraint { public boolean eval( Object o ) { return true; } @@ -53,6 +55,38 @@ assertTrue( p.eval( new Integer(1) ) ); assertTrue( !p.eval(i2) ); } + + public void testIsEqualObjectArray() { + 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) ); + } + + public void testIsEqualToStringForNestedConstraint() { + assertEquals("Should get an obvious toString to reflect nesting if viewed in a debugger", + " = = NestedConstraint", new IsEqual(new IsEqual("NestedConstraint")).toString()); + } + 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()); + } + + public void testIsEqualEquals() throws Exception { + assertEquals("Should be equal", new IsEqual("a"), new IsEqual("a")); + 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) ); |