public static FaturamentoLoterica GetFaturamento() { Concurso concurso = Loterica.Common.Tests.Concursos.ObjectMother.GetConcursoComId(); FaturamentoLoterica faturamento = new FaturamentoLoterica(concurso); return(faturamento); }
public void Integration_ExcluirFaturamentoLoterica_Incorretamente_Retornando_Excecao() { FaturamentoLoterica faturamentoLoterica = Loterica.Common.Tests.Lotericas.ObjectMother.GetFaturamentoComId(); Action action = () => _service.Excluir(faturamentoLoterica); action.Should().Throw <UnsupportedOperationException>(); }
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); }
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); }
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>(); }
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>(); }
public ResultadoConcurso(Concurso concurso) { this.concurso = concurso; faturamento = new FaturamentoLoterica(concurso); ganhadores = new List <Ganhador>(); numerosResultado = new List <int>(); CalculaNumeroResultado(new Random()); CalcularPremioTotal(); }
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>(); }
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>(); }
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>(); }
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); }
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 } }); }
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); }
public FaturamentoLoterica GetById(int Id) { Dictionary <string, object> parms = new Dictionary <string, object> { { "Id", Id } }; FaturamentoLoterica faturamento = Db.Get(_sqlGet, Make, parms); return(faturamento); }
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(); }
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)); }
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)); }
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); }
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); }
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)); }
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(); } } }
public void Infra_FaturamentoLoterica_SQLRepository_Deveria_Adicionar() { _faturamentoLoterica = Loterica.Common.Tests.Lotericas.ObjectMother.GetFaturamento(); _faturamentoLoterica = _faturamentoLotericaRepository.Adicionar(_faturamentoLoterica); _faturamentoLoterica.Id.Should().Be(2); }
public void Editar(FaturamentoLoterica entidade) { entidade.Validar(); Db.Update(_sqlUpdate, Take(entidade)); }
public FaturamentoLoterica Adicionar(FaturamentoLoterica entidade) { entidade.Validar(); entidade.Id = Db.Insert(_sqlAdd, Take(entidade)); return(entidade); }
public void Infra_FaturamentoLoterica_SQLRepository_Deveria_PegarPorId() { FaturamentoLoterica faturamento = _faturamentoLotericaRepository.GetById(1); faturamento.Should().NotBeNull(); }
public void Infra_FaturamentoLoterica_SQLRepository_Deveria_Pegar_Por_ConcursoId() { _faturamentoLoterica = _faturamentoLotericaRepository.GetByConcursoId(2); _faturamentoLoterica.concurso.Id.Should().Be(2); }
public void Integration_PegarConcursoIdDeFaturamentoLoterica_Corretamente() { FaturamentoLoterica f = _service.GetByConcursoId(2); f.Should().NotBeNull(); }
public void Integration_PegarFaturamentoLotericaPorId_Corretamente() { FaturamentoLoterica f = _service.Get(1); f.Should().NotBeNull(); }