Skip to content

Instantly share code, notes, and snippets.

@AlfredoCasado
Created January 23, 2011 21:07
Show Gist options
  • Save AlfredoCasado/792441 to your computer and use it in GitHub Desktop.
Save AlfredoCasado/792441 to your computer and use it in GitHub Desktop.
public class CompraTestSpies {
PasarelaDePago pasarelaDePagoSpy = mock(PasarelaDePago.class);
Producto unProductoStub = mock(Producto.class);
Compra compra = new Compra(pasarelaDePagoSpy);
@Test public void
si_el_cliente_tiene_fondos_para_realizar_la_compra_tengo_que_cobrarle_a_traves_de_la_pasarela_de_pago() {
when(unProductoStub.precio()).thenReturn(50);
when(pasarelaDePagoSpy.tieneElUsuarioFondosPorValorDe(50)).thenReturn(false);
compra.anadir(unProductoStub);
compra.confirmar();
verify(pasarelaDePagoSpy).cobrar(50);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment