Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package br.com.caelum.leilao.servico; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import br.com.caelum.leilao.dominio.Lance; | ||
import br.com.caelum.leilao.dominio.Leilao; | ||
import br.com.caelum.leilao.dominio.Usuario; | ||
|
||
public class AvaliadorTest { | ||
|
||
@Test | ||
public void deveEntenderLancesEmOrdemCrescente() { | ||
// cenario: 3 lances em ordem crescente | ||
Usuario joao = new Usuario("Joao"); | ||
Usuario jose = new Usuario("José"); | ||
Usuario maria = new Usuario("Maria"); | ||
|
||
Leilao leilao = new Leilao("Playstation 3 Novo"); | ||
|
||
leilao.propoe(new Lance(maria,250.0)); | ||
leilao.propoe(new Lance(joao,300.0)); | ||
leilao.propoe(new Lance(jose,400.0)); | ||
|
||
// executando a acao | ||
Avaliador leiloeiro = new Avaliador(); | ||
leiloeiro.avalia(leilao); | ||
|
||
// comparando a saida com o esperado | ||
double maiorEsperado = 400; | ||
double menorEsperado = 250; | ||
|
||
Assert.assertEquals(maiorEsperado, leiloeiro.getMaiorLance(), 0.0001); | ||
Assert.assertEquals(menorEsperado, leiloeiro.getMenorLance(), 0.0001); | ||
} | ||
|
||
@Test | ||
public void deveCalcularAMedia() { | ||
Usuario joao = new Usuario("Joao"); | ||
Usuario jose = new Usuario("José"); | ||
Usuario maria = new Usuario("Maria"); | ||
|
||
Leilao leilao = new Leilao("Playstation 3 Novo"); | ||
|
||
leilao.propoe(new Lance(maria,300.0)); | ||
leilao.propoe(new Lance(joao,400.0)); | ||
leilao.propoe(new Lance(jose,500.0)); | ||
|
||
Avaliador leiloeiro = new Avaliador(); | ||
leiloeiro.avalia(leilao); | ||
|
||
Assert.assertEquals(400, leiloeiro.getMedia(), 0.0001); | ||
} | ||
|
||
} |
Binary file added
BIN
+1.82 KB
target/classes-teste/br/com/caelum/leilao/servico/AvaliadorTest.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions
5
target/reports/TEST-br.com.caelum.leilao.servico.AvaliadorTest.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Testsuite: br.com.caelum.leilao.servico.AvaliadorTest | ||
Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.017 sec | ||
|
||
Testcase: deveCalcularAMedia took 0.004 sec | ||
Testcase: deveEntenderLancesEmOrdemCrescente took 0 sec |