Created
January 12, 2011 14:01
-
-
Save AlfredoCasado/776187 to your computer and use it in GitHub Desktop.
Ejemplo stub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CompraTest { | |
Producto unProductoStub = mock(Producto.class); | |
Producto otroProductoStub = mock(Producto.class); | |
PasarelaDePago pasarelaDePagoStub = mock(PasarelaDePago.class); | |
Compra compra = new Compra(pasarelaDePagoStub); | |
@Test public void | |
si_el_cliente_tiene_fondos_para_realizar_la_compra_la_puedo_confirmar() { | |
when(unProductoStub.precio()).thenReturn(50); | |
when(otroProductoStub.precio()).thenReturn(25); | |
when(pasarelaDePagoStub.tieneElUsuarioFondosPorValorDe(75)).thenReturn(true); | |
compra.anadir(unProductoStub); | |
compra.anadir(otroProductoStub); | |
assertTrue(compra.confirmar()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment