Beispiel #1
0
        public void NaoDeveAceitarDoisLancesSeguidosDoMesmoUsuario()
        {
            Leilao leilao    = new Leilao("Macbook Pro 15");
            var    steveJobs = new Usuario("Steve Jobs");

            leilao.Propoe(new Lance(steveJobs, 2000));
            leilao.Propoe(new Lance(steveJobs, 3000));

            Assert.AreEqual(1, leilao.Lances.Count);
            Assert.AreEqual(2000, leilao.Lances[0].Valor, 0.0001);
        }
Beispiel #2
0
        public void DeveReceberVariosLances()
        {
            Leilao leilao = new Leilao("Macbook Pro 15");

            leilao.Propoe(new Lance(new Usuario("Steve Jobs"), 2000));
            leilao.Propoe(new Lance(new Usuario("Steve Wozniak"), 3000));

            Assert.AreEqual(2, leilao.Lances.Count);
            Assert.AreEqual(2000, leilao.Lances[0].Valor, 0.00001);
            Assert.AreEqual(3000, leilao.Lances[1].Valor, 0.00001);
        }
        public void DeveAceitarDobrarOLanceDeUsuariosDiferentes()
        {
            Leilao  leilao    = new Leilao("Macbook Pro 15");
            Usuario steveJobs = new Usuario("Steve Jobs");
            Usuario billGates = new Usuario("Bill Gates");

            leilao.Propoe(new Lance(steveJobs, 2000));
            leilao.Propoe(new Lance(billGates, 3000));
            leilao.DobraLance(steveJobs);

            Assert.AreEqual(4000, leilao.Lances[2].Valor, 0.00001);
        }
Beispiel #4
0
        public void DeveEntenderLancesEmOrdemCrescente()
        {
            //cenario
            Leilao leilao = new Leilao("Playstation 3 Novo");

            leilao.Propoe(new Lance(joao, 300));
            leilao.Propoe(new Lance(jose, 400));
            leilao.Propoe(new Lance(maria, 250));

            //acao
            leiloeiro.Avalia(leilao);

            //validacao
            double maiorEsperado = 400;
            double menorEsperado = 250;

            Assert.AreEqual(maiorEsperado, leiloeiro.MaiorLance);
            Assert.AreEqual(menorEsperado, leiloeiro.MenorLance);
        }
        public void DeveReceberUmLance()
        {
            Leilao leilao = new Leilao("MacBook Pro 15");

            Assert.AreEqual(0, leilao.Lances.Count);

            leilao.Propoe(new Lance(new Usuario("Steve Jobs"), 2000));
            Assert.AreEqual(1, leilao.Lances.Count);
            Assert.AreEqual(2000, leilao.Lances[0].Valor, 0.0001);
        }
Beispiel #6
0
 public CriadorDeLeilao Lance(Usuario usuario, double valor)
 {
     leilao.Propoe(new Lance(usuario, valor));
     return(this);
 }
Beispiel #7
0
        public void NaoDeveAceitarMaisDoQue5LancesDeUmMesmoUsuario()
        {
            Leilao  leilao    = new Leilao("Macbook Pro 15");
            Usuario steveJobs = new Usuario("Steve Jobs");
            Usuario billGates = new Usuario("Bill Gates");

            leilao.Propoe(new Lance(steveJobs, 1000));
            leilao.Propoe(new Lance(billGates, 2000));

            leilao.Propoe(new Lance(steveJobs, 3000));
            leilao.Propoe(new Lance(billGates, 4000));

            leilao.Propoe(new Lance(steveJobs, 5000));
            leilao.Propoe(new Lance(billGates, 6000));

            leilao.Propoe(new Lance(steveJobs, 7000));
            leilao.Propoe(new Lance(billGates, 8000));

            leilao.Propoe(new Lance(steveJobs, 9000));
            leilao.Propoe(new Lance(billGates, 10000));

            leilao.Propoe(new Lance(steveJobs, 11000));

            Assert.AreEqual(10, leilao.Lances.Count);
            var   ultimo      = leilao.Lances.Count - 1;
            Lance ultimoLance = leilao.Lances[ultimo];

            Assert.AreEqual(10000, ultimoLance.Valor, 0.00001);
        }
        public void NaoDeveAceitarMaisQueCincoLancesDoMesmoUsuario()
        {
            Leilao  leilao       = new Leilao("Carro esportivo");
            Usuario steveJobs    = new Usuario("Steve Jobs");
            Usuario steveWozniak = new Usuario("Steve Wozniak");

            leilao.Propoe(new Lance(steveJobs, 2000));
            leilao.Propoe(new Lance(steveWozniak, 3000));
            leilao.Propoe(new Lance(steveJobs, 3100));
            leilao.Propoe(new Lance(steveWozniak, 3200));
            leilao.Propoe(new Lance(steveJobs, 3300));
            leilao.Propoe(new Lance(steveWozniak, 3400));
            leilao.Propoe(new Lance(steveJobs, 3500));
            leilao.Propoe(new Lance(steveWozniak, 3600));
            leilao.Propoe(new Lance(steveJobs, 3800));
            leilao.Propoe(new Lance(steveWozniak, 3800));

            leilao.Propoe(new Lance(steveJobs, 3900));

            Assert.AreEqual(10, leilao.Lances.Count);
            var   ultimo      = leilao.Lances.Count - 1;
            Lance ultimoLance = leilao.Lances[ultimo];

            Assert.AreEqual(3800, ultimoLance.Valor, 0.0001);
        }