예제 #1
0
        public static FaturamentoLoterica GetFaturamento()
        {
            Concurso            concurso    = Loterica.Common.Tests.Concursos.ObjectMother.GetConcursoComId();
            FaturamentoLoterica faturamento = new FaturamentoLoterica(concurso);

            return(faturamento);
        }
예제 #2
0
        public void Integration_ExcluirFaturamentoLoterica_Incorretamente_Retornando_Excecao()
        {
            FaturamentoLoterica faturamentoLoterica = Loterica.Common.Tests.Lotericas.ObjectMother.GetFaturamentoComId();
            Action action = () => _service.Excluir(faturamentoLoterica);

            action.Should().Throw <UnsupportedOperationException>();
        }
예제 #3
0
        public void Service_CSV_Exportar_Resultado()
        {
            _concurso = ObjectMother.GetConcursoComId();
            ResultadoConcurso   resultadoConcurso = new ResultadoConcurso(_concurso);
            FaturamentoLoterica faturamento       = Loterica.Common.Tests.Lotericas.ObjectMother.GetFaturamentoComId();
            List <Aposta>       apostas           = Loterica.Common.Tests.Apostas.ObjectMother.GetApostas();

            _apostaRepository
            .Setup(x => x.GetByConcursoId(It.IsAny <int>()))
            .Returns(apostas);

            _apostaRepository
            .Setup(x => x.GetByConcursoIdComBolao(It.IsAny <int>()))
            .Returns(apostas);

            _resultadoConcursoRepository
            .Setup(y => y.Adicionar(It.IsAny <ResultadoConcurso>()));

            randomMoq
            .Setup(r => r.Next(1, 61))
            .Returns(() => numeroAleatorio++);

            resultadoConcurso = _resultadoConcurso.GerarResultadoConcurso(resultadoConcurso, randomMoq.Object);
            List <ResultadoConcurso> resultado = new List <ResultadoConcurso>();

            resultado.Add(resultadoConcurso);
            _csvService.ExportarCSV(resultado, file);
            FileAssert.Exists(file);
        }
예제 #4
0
 public void Domain_FaturamentoLoterica_Calcular_Faturamento_Lucro()
 {
     _faturamento = Loterica.Common.Tests.Lotericas.ObjectMother.GetFaturamento();
     _faturamento.CalcularFaturamentoELucro(10, 2);
     _faturamento.lucro.Should().Be(3.30);
     _faturamento.faturamento.Should().Be(30.30);
 }
예제 #5
0
        public void Infra_FaturamentoLoterica_SQLRepository_Deveria_Lançar_Exceçao_No_Excluir()
        {
            _faturamentoLoterica = Loterica.Common.Tests.Lotericas.ObjectMother.GetFaturamentoComId();
            Action action = () => _faturamentoLotericaRepository.Excluir(_faturamentoLoterica.Id);

            action.Should().Throw <UnsupportedOperationException>();
        }
예제 #6
0
        public void Domain_FaturamentoLoterica_Validar_Faturamento_Negativo()
        {
            _faturamento             = Loterica.Common.Tests.Lotericas.ObjectMother.GetFaturamento();
            _faturamento.faturamento = -2;
            Action action = () => _faturamento.Validar();

            action.Should().Throw <InvalidFaturamentoException>();
        }
예제 #7
0
 public ResultadoConcurso(Concurso concurso)
 {
     this.concurso    = concurso;
     faturamento      = new FaturamentoLoterica(concurso);
     ganhadores       = new List <Ganhador>();
     numerosResultado = new List <int>();
     CalculaNumeroResultado(new Random());
     CalcularPremioTotal();
 }
예제 #8
0
        public void Domain_FaturamentoLoterica_Validar_Should_Be_Ok()
        {
            _faturamento             = Loterica.Common.Tests.Lotericas.ObjectMother.GetFaturamento();
            _faturamento.faturamento = 20;
            _faturamento.lucro       = 10;
            Action action = () => _faturamento.Validar();

            action.Should().NotThrow <Exception>();
        }
예제 #9
0
        public void Domain_FaturamentoLoterica_Validar_Faturamento_Maior_Que_Lucro()
        {
            _faturamento             = Loterica.Common.Tests.Lotericas.ObjectMother.GetFaturamento();
            _faturamento.faturamento = 10;
            _faturamento.lucro       = 20;
            Action action = () => _faturamento.Validar();

            action.Should().Throw <InvalidFaturamentoException>();
        }
예제 #10
0
        public void Infra_FaturamentoLoterica_SQLRepository_Nao_Deveria_AlterarLucro_Maior_Que_Faturamento()
        {
            _faturamentoLoterica             = Loterica.Common.Tests.Lotericas.ObjectMother.GetFaturamentoComId();
            _faturamentoLoterica.lucro       = 20000;
            _faturamentoLoterica.faturamento = 10000;
            Action action = () => _faturamentoLotericaRepository.Editar(_faturamentoLoterica);

            action.Should().Throw <InvalidFaturamentoException>();
        }
예제 #11
0
        public void Integration_EditarFaturamentoLoterica_Corretamente()
        {
            FaturamentoLoterica faturamentoLoterica = Loterica.Common.Tests.Lotericas.ObjectMother.GetFaturamentoComId();

            faturamentoLoterica.CalcularFaturamentoELucro(10, 2);
            _service.Editar(faturamentoLoterica);
            FaturamentoLoterica f = _service.Get(faturamentoLoterica.Id);

            f.lucro.Should().Be(faturamentoLoterica.lucro);
        }
예제 #12
0
 private Dictionary <string, object> Take(FaturamentoLoterica faturamento)
 {
     return(new Dictionary <string, object>
     {
         { "Id", faturamento.Id },
         { "Lucro", faturamento.lucro },
         { "Faturamento", faturamento.faturamento },
         { "ConcursoId", faturamento.concurso.Id }
     });
 }
예제 #13
0
        public void Infra_FaturamentoLoterica_SQLRepository_Deveria_Alterar()
        {
            _faturamentoLoterica = Loterica.Common.Tests.Lotericas.ObjectMother.GetFaturamentoComId();
            _faturamentoLotericaRepository.Editar(_faturamentoLoterica);
            FaturamentoLoterica f = _faturamentoLotericaRepository.GetById(_faturamentoLoterica.Id);

            f.Id.Should().Be(_faturamentoLoterica.Id);
            f.lucro.Should().Be(_faturamentoLoterica.lucro);
            f.faturamento.Should().Be(_faturamentoLoterica.faturamento);
        }
예제 #14
0
        public FaturamentoLoterica GetById(int Id)
        {
            Dictionary <string, object> parms = new Dictionary <string, object> {
                { "Id", Id }
            };

            FaturamentoLoterica faturamento = Db.Get(_sqlGet, Make, parms);

            return(faturamento);
        }
예제 #15
0
        public void Service_FaturamentoLoterica_Nao_Deve_Editar_Caso_Nao_Passe_Na_Validacao()
        {
            _faturamentoLoterica = Loterica.Common.Tests.Lotericas.ObjectMother.GetFaturamentoComId();
            _faturamentoLoterica.CalcularFaturamentoELucro(100, 10);
            _faturamentoLoterica.lucro = 1000;

            Action action = () => _service.Editar(_faturamentoLoterica);

            action.Should().Throw <InvalidFaturamentoException>();
            _faturamentoLotericaRepository.VerifyNoOtherCalls();
        }
예제 #16
0
        public void Service_FaturamentoLoterica_Deveria_Editar_Faturamento()
        {
            _faturamentoLoterica = Loterica.Common.Tests.Lotericas.ObjectMother.GetFaturamentoComId();
            _faturamentoLoterica.CalcularFaturamentoELucro(100, 10);

            _faturamentoLotericaRepository
            .Setup(x => x.Editar(It.IsAny <FaturamentoLoterica>()));

            _service.Editar(_faturamentoLoterica);

            _faturamentoLotericaRepository.Verify(x => x.Editar(_faturamentoLoterica));
        }
예제 #17
0
        public void Service_FaturamentoLoterica_Deveria_Chamar_Excluir_Faturamento_do_Repository()
        {
            _faturamentoLoterica = Loterica.Common.Tests.Lotericas.ObjectMother.GetFaturamentoComId();
            _faturamentoLoterica.CalcularFaturamentoELucro(100, 10);

            _faturamentoLotericaRepository
            .Setup(x => x.Excluir(It.IsAny <int>()));

            _service.Excluir(_faturamentoLoterica);

            _faturamentoLotericaRepository.Verify(x => x.Excluir(_faturamentoLoterica.Id));
        }
예제 #18
0
        private FaturamentoLoterica Make(IDataReader reader)
        {
            Concurso            concurso    = new Concurso();
            FaturamentoLoterica faturamento = new FaturamentoLoterica(concurso);

            faturamento.Id                         = Convert.ToInt32(reader["Id"]);
            faturamento.lucro                      = Convert.ToDouble(reader["Lucro"]);
            faturamento.faturamento                = Convert.ToDouble(reader["Faturamento"]);
            faturamento.concurso.Id                = Convert.ToInt32(reader["ConcursoId"]);
            faturamento.concurso.dataFechamento    = Convert.ToDateTime(reader["DataFechamento"]);
            faturamento.concurso.valorTotalApostas = Convert.ToDouble(reader["ValorTotalApostas"]);

            return(faturamento);
        }
예제 #19
0
        public void Service_FaturamentoLoterica_Deveria_Chamar_GetByConcursoId_do_Repository()
        {
            _faturamentoLoterica = Loterica.Common.Tests.Lotericas.ObjectMother.GetFaturamentoComId();
            _faturamentoLoterica.CalcularFaturamentoELucro(1000, 10);

            _faturamentoLotericaRepository
            .Setup(x => x.GetByConcursoId(It.IsAny <int>()))
            .Returns(_faturamentoLoterica);

            FaturamentoLoterica faturamentoRecebido = _service.GetByConcursoId(_faturamentoLoterica.concurso.Id);

            _faturamentoLotericaRepository
            .Verify(x => x.GetByConcursoId(_faturamentoLoterica.concurso.Id));

            faturamentoRecebido.Should().BeEquivalentTo(_faturamentoLoterica);
        }
예제 #20
0
        public void Service_FaturamentoLoterica_Deveria_Adicionar_Faturamento()
        {
            _faturamentoLoterica = Loterica.Common.Tests.Lotericas.ObjectMother.GetFaturamento();
            _faturamentoLoterica.CalcularFaturamentoELucro(100, 10);

            _faturamentoLotericaRepository
            .Setup(x => x.Adicionar(It.IsAny <FaturamentoLoterica>()))
            .Returns(
                new FaturamentoLoterica(_faturamentoLoterica.concurso)
            {
                Id          = 1,
                faturamento = _faturamentoLoterica.faturamento,
                lucro       = _faturamentoLoterica.lucro
            });

            _service.Adicionar(_faturamentoLoterica);

            _faturamentoLotericaRepository.Verify(x => x.Adicionar(_faturamentoLoterica));
        }
예제 #21
0
        public void Service_ResultadoConcurso_Deveria_Adicionar_ResultadoConcurso()
        {
            _concurso = ObjectMother.GetConcursoComId();
            ResultadoConcurso   resultado   = new ResultadoConcurso(_concurso);
            FaturamentoLoterica faturamento = Loterica.Common.Tests.Lotericas.ObjectMother.GetFaturamentoComId();
            List <Aposta>       apostas     = Loterica.Common.Tests.Apostas.ObjectMother.GetApostas();

            _apostaRepository
            .Setup(x => x.GetByConcursoId(It.IsAny <int>()))
            .Returns(apostas);

            _apostaRepository
            .Setup(x => x.GetByConcursoIdComBolao(It.IsAny <int>()))
            .Returns(apostas);

            _resultadoConcursoRepository
            .Setup(y => y.Adicionar(It.IsAny <ResultadoConcurso>()));

            randomMoq
            .Setup(r => r.Next(1, 61))
            .Returns(() => numeroAleatorio++);

            resultado = _service.GerarResultadoConcurso(resultado, randomMoq.Object);
            _service.Adicionar(resultado);

            _apostaRepository
            .Verify(x => x.GetByConcursoId(_concurso.Id));

            _resultadoConcursoRepository
            .Verify(y => y.Adicionar(resultado));

            resultado.premioTotal.Should().Be(7200.9);
            resultado.numerosResultado.Count().Should().Be(6);
            foreach (var item in resultado.numerosResultado)
            {
                if (item > 60 || item < 1)
                {
                    Assert.Fail();
                }
            }
        }
예제 #22
0
 public void Infra_FaturamentoLoterica_SQLRepository_Deveria_Adicionar()
 {
     _faturamentoLoterica = Loterica.Common.Tests.Lotericas.ObjectMother.GetFaturamento();
     _faturamentoLoterica = _faturamentoLotericaRepository.Adicionar(_faturamentoLoterica);
     _faturamentoLoterica.Id.Should().Be(2);
 }
예제 #23
0
 public void Editar(FaturamentoLoterica entidade)
 {
     entidade.Validar();
     Db.Update(_sqlUpdate, Take(entidade));
 }
예제 #24
0
 public FaturamentoLoterica Adicionar(FaturamentoLoterica entidade)
 {
     entidade.Validar();
     entidade.Id = Db.Insert(_sqlAdd, Take(entidade));
     return(entidade);
 }
예제 #25
0
        public void Infra_FaturamentoLoterica_SQLRepository_Deveria_PegarPorId()
        {
            FaturamentoLoterica faturamento = _faturamentoLotericaRepository.GetById(1);

            faturamento.Should().NotBeNull();
        }
예제 #26
0
 public void Infra_FaturamentoLoterica_SQLRepository_Deveria_Pegar_Por_ConcursoId()
 {
     _faturamentoLoterica = _faturamentoLotericaRepository.GetByConcursoId(2);
     _faturamentoLoterica.concurso.Id.Should().Be(2);
 }
예제 #27
0
        public void Integration_PegarConcursoIdDeFaturamentoLoterica_Corretamente()
        {
            FaturamentoLoterica f = _service.GetByConcursoId(2);

            f.Should().NotBeNull();
        }
예제 #28
0
        public void Integration_PegarFaturamentoLotericaPorId_Corretamente()
        {
            FaturamentoLoterica f = _service.Get(1);

            f.Should().NotBeNull();
        }