public void ridiculousJavaTypeName() { @SuppressWarnings("unused") final List<List<Set<String>>> silly = Collections.emptyList(); context.checking(new Expectations() {{ oneOf (mock).beSilly(with.<List<List<Set<String>>>>is(empty())); }}); } }
public void testAllOrNoneOfTheParametersMustBeSpecifiedByMatchers() { try { context.checking(new Expectations() {{ oneOf (mock).doSomethingWithBoth(with.<String>is(equal("a-matcher")), "not-a-matcher"); }}); } catch (IllegalArgumentException expected) { } }
public void testMatchesParameterValues() { context.checking(new Expectations() {{ oneOf (mock).doSomethingWith(with.<String>is(equal("hello"))); oneOf (mock).doSomethingWith(with.<String>is(equal("goodbye"))); }}); mock.doSomethingWith("hello"); mock.doSomethingWith("goodbye"); context.assertIsSatisfied(); }
public void testNotAllExpectationsOfSameMockMustUseMatchers() { context.checking(new Expectations() {{ oneOf (mock).doSomethingWithBoth(with.<String>is(equal("x")), with.<String>is(equal("y"))); oneOf (mock).doSomethingWith("z"); }}); mock.doSomethingWithBoth("x", "y"); mock.doSomethingWith("z"); context.assertIsSatisfied(); }
public void testDoesNotAllowUnexpectedParameterValues() { context.checking(new Expectations() {{ oneOf (mock).doSomethingWith(with.<String>is(equal("hello"))); oneOf (mock).doSomethingWith(with.<String>is(equal("goodbye"))); }}); try { mock.doSomethingWith("hello"); mock.doSomethingWith("Goodbye"); fail("should have thrown ExpectationError"); } catch (ExpectationError expected) {} }
public void testCanPassLiteralValuesToWithMethodToMeanEqualTo() { context.checking(new Expectations() {{ exactly(2).of (mock).doSomethingWithBoth(with.<String>is(anything()), with("y")); }}); mock.doSomethingWithBoth("x", "y"); mock.doSomethingWithBoth("z", "y"); context.assertIsSatisfied(); }