public void MaximoCincoLancePorUsuarioDobraLance()
        {
            var leilao = new Leilao("Yamaha Fazer 250");

            var tiao  = new Usuario("Sebastiao");
            var tiago = new Usuario("Tiago");

            leilao.Propoe(new Lance(tiao, 1000));
            leilao.Propoe(new Lance(tiago, 1100));

            leilao.DobraLance(tiao);
            leilao.DobraLance(tiago);
            leilao.DobraLance(tiao);
            leilao.DobraLance(tiago);
            leilao.DobraLance(tiao);
            leilao.DobraLance(tiago);
            leilao.DobraLance(tiao);
            leilao.DobraLance(tiago);
            leilao.DobraLance(tiao);
            leilao.DobraLance(tiago);

            Assert.AreEqual(10, leilao.Lances.Count);
            Assert.AreEqual(tiago, leilao.Lances[leilao.Lances.Count - 1].Usuario);
            Assert.AreEqual(17600d, leilao.Lances[leilao.Lances.Count - 1].ValorLance);
        }
Esempio n. 2
0
        public void NaoDeveDobrarCasoNaoHajaLanceAnterior()
        {
            Leilao leilao = new Leilao("Macbook Pro 15");

            leilao.DobraLance(stevejobs);

            Assert.AreEqual(0, leilao.Lances.Count);
        }
Esempio n. 3
0
        public void NaoDeveDobrarLanceParaUsuarioQueNuncaPropos()
        {
            Usuario usuario = new Usuario("Nome");
            Leilao leilao = new Leilao("Descricao");

            leilao.DobraLance(usuario);

            Assert.AreEqual(0, leilao.Lances.Count);
        }
Esempio n. 4
0
        public void DeveDobrarOUltimoLanceDado()
        {
            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);
        }
Esempio n. 5
0
        public void DeveDobrarOLanceAnteriorDeUmUsuario()
        {
            Usuario usuario1 = new Usuario("Nome1");
            Usuario usuario2 = new Usuario("Nome2");
            Leilao leilao = new Leilao("Descricao");

            leilao.Propoe(new Lance(usuario1, 1));
            leilao.Propoe(new Lance(usuario2, 3));
            leilao.DobraLance(usuario1);

            int contagem = leilao.Lances.Count;
            Assert.AreEqual(3, contagem);
            Assert.AreEqual(2, leilao.Lances[contagem - 1].Valor);
        }
Esempio n. 6
0
        public void UsuarioDobraOLance()
        {
            Leilao leilao = new Leilao("Macbook Pro 15");

            leilao.Propoe(new Lance(stevejobs, 2000));
            leilao.Propoe(new Lance(billgates, 3000));

            leilao.DobraLance(stevejobs);

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

            Assert.AreEqual(4000.0, ultimoLance.Valor, 0.00001);
            Assert.AreEqual(stevejobs, ultimoLance.Usuario);
        }
Esempio n. 7
0
        public void Should_double_throw()
        {
            //Given
            Leilao  leilao    = new Leilao("Macbook Pro 15");
            Usuario steveJobs = new Usuario("Steve Jobs");
            Usuario billGates = new Usuario("Bill Gates");

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

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

            leilao.DobraLance(steveJobs);

            //Then
            Assert.Equal(5, leilao.Lances.Count);
            var   ultimo      = leilao.Lances.Count - 1;
            Lance ultimoLance = leilao.Lances[ultimo];

            Assert.Equal(steveJobs, ultimoLance.Usuario);
            Assert.Equal(8000, ultimoLance.Valor, 4);
        }
Esempio n. 8
0
        public void UsuarioCom5LancesDobraOLance()
        {
            Leilao leilao = new Leilao("Macbook Pro 15");

            leilao.Propoe(new Lance(stevejobs, 2000));
            leilao.Propoe(new Lance(billgates, 3000));
            leilao.Propoe(new Lance(stevejobs, 4000));
            leilao.Propoe(new Lance(billgates, 5000));
            leilao.Propoe(new Lance(stevejobs, 6000));
            leilao.Propoe(new Lance(billgates, 7000));
            leilao.Propoe(new Lance(stevejobs, 8000));
            leilao.Propoe(new Lance(billgates, 9000));
            leilao.Propoe(new Lance(stevejobs, 10000));
            leilao.Propoe(new Lance(billgates, 11000));

            // deve ser ignorado
            leilao.DobraLance(stevejobs);

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

            Assert.AreEqual(11000.0, ultimoLance.Valor, 0.00001);
        }