Exemplo n.º 1
0
  @Test
  public void testAcceptsExceptionsAsValidExpectations() throws Exception {
    StaticInvocation divide = new StaticInvocation(calculator, Calculator.DIVIDE);
    Call call = new Call(divide);
    call.addInput("7", "0");
    call.expect(ShouldBe.instanceOf(ArithmeticException.class));

    call.execute();
    assertTrue(call.wasRight());
  }
Exemplo n.º 2
0
  @Test
  public void testReportsASuccessIfOuputMatchesExpectation() throws Exception {
    Call call = new Call(new StaticInvocation(calculator, Calculator.SUM));
    call.addInput("5", "2");
    call.expect(ShouldBe.equal(7));

    call.will(Annotate.right(annotatable)).when(ResultIs.right());
    call.execute();
    verify(annotatable).annotate(any(RightAnnotation.class));
  }
Exemplo n.º 3
0
  @Test
  public void testReportsAFailureIfOuputIsUnexpected() throws Exception {
    Call call = new Call(new StaticInvocation(calculator, Calculator.ADD));
    call.addInput("3");
    call.expect(ShouldBe.equal(3));

    call.will(Annotate.wrong(annotatable)).when(ResultIs.wrong());
    call.execute();
    verify(annotatable).annotate(any(WrongAnnotation.class));
  }
 public boolean equal() {
   return ShouldBe.literal(expectedValue).meets(actualValue);
 }