Esempio n. 1
0
  private void assertReportWrongNumberOfMatchers(TestInterface testObject) {
    Recorder<TestInterface> recorder = TestObject.createRecorder(testObject);

    recorder
        .record(testObject.methodWithArguments((String) recorder.matchObject(Any.ANY), 10))
        .andReturn("value");
  }
Esempio n. 2
0
  private void assertUseCustomMatcher(TestInterface testObject) {
    String returnedValue = "returnedValue";
    String stringArg = "stringarg";
    int intArg = -1;
    Recorder<TestInterface> recorder = new Recorder<TestInterface>(testObject);
    recorder
        .record(
            testObject.methodWithArguments(
                (String)
                    recorder.matchObject(
                        new Matcher() {
                          @Override
                          public boolean matches(Object aActual) {
                            return ((String) aActual).startsWith("s");
                          }
                        }),
                recorder.matchInt(
                    new Matcher() {
                      @Override
                      public boolean matches(Object aActual) {
                        return ((Integer) aActual).intValue() < 0;
                      }
                    })))
        .andReturn(returnedValue);

    String actual = testObject.methodWithArguments(stringArg, intArg);
    assertEquals(actual, returnedValue);
  }
Esempio n. 3
0
  private void assertUseLooseArgumentMatching(TestInterface testObject) {
    String returnedValue = "returnedValue";
    Recorder<TestInterface> recorder = TestObject.createRecorder(testObject);
    recorder
        .record(
            testObject.methodWithArguments(
                (String) recorder.matchObject(Any.ANY), recorder.matchInt(Any.ANY)))
        .andReturn(returnedValue);

    String actual = testObject.methodWithArguments("otherArg", -1);
    ;
    assertEquals(actual, returnedValue);
  }
Esempio n. 4
0
  private void assertEqMatcher(TestInterface testObject) {
    String returnedValue = "returnedValue";
    String stringArg = "stringarg";
    int intArg = -1;
    Recorder<TestInterface> recorder = TestObject.createRecorder(testObject);
    recorder
        .record(
            testObject.methodWithArguments(
                (String) recorder.matchObject(new Eq(stringArg)),
                recorder.matchInt(new Eq(intArg))))
        .andReturn(returnedValue);

    String actual = testObject.methodWithArguments(stringArg, intArg);
    assertEquals(actual, returnedValue);
  }