Beispiel #1
0
 public IntegrationTest()
 {
     context         = new ErpContext();
     _jogadorService = new JogadorService(new UnitOfWork <ErpContext>(context));
     _jogoService    = new JogoService(new UnitOfWork <ErpContext>(context));
     _sorteioService = new SorteioService(new UnitOfWork <ErpContext>(context));
 }
Beispiel #2
0
 public PedidosController(PedidoService pedidoService, ClienteService clienteService, JogoService jogoService, ConsoleService consoleService)
 {
     _pedidoService  = pedidoService;
     _clienteService = clienteService;
     _jogoService    = jogoService;
     _consoleService = consoleService;
 }
Beispiel #3
0
        public void Setup()
        {
            _jogoRepositoryMock = new Mock <IJogoRepository>();

            _jogoService = new JogoService
            {
                _jogoRepository = _jogoRepositoryMock.Object
            };
        }
Beispiel #4
0
        private void btnSalvar_Click(object sender, System.EventArgs e)
        {
            JogoService service = new JogoService();

            int    placar   = Convert.ToInt32(txtPlacar.Text);
            JogoBE novoJogo = new JogoBE(placar);

            service.CadastrarNovoJogo(novoJogo);
            _frmListagemJogos.CarregarListaJogos();
            this.Close();
        }
        public void Domain_Deve_Retornar_Todos_Jogos()
        {
            var expectResult = new ResultBag <IEnumerable <JogoBasquete> >(true, _listaJogosTeste);

            _mockJogoRepository.Setup(s => s.GetJogos()).Returns(expectResult);

            var jogoService = new JogoService(_mockJogoRepository.Object);
            var result      = jogoService.GetJogos();

            _mockJogoRepository.Verify(v => v.GetJogos(), Times.Once);

            Assert.AreEqual(expectResult.Message, result.Message);
            Assert.AreEqual(expectResult.IsSuccess, result.IsSuccess);
            Assert.AreEqual(expectResult.Data, result.Data);
        }
        public void Domain_Deve_Retornar_Erro_Ao_Adicionar_Novo_Jogo()
        {
            var novoJogo     = new JogoBasquete(0, DateTime.Now, 25);
            var expectResult = new ResultBag("Erro ao adicionar novo Jogo!", false);

            _mockJogoRepository.Setup(s => s.AddJogo(It.IsAny <JogoBasquete>())).Returns(expectResult);

            var jogoService = new JogoService(_mockJogoRepository.Object);
            var result      = jogoService.AddJogo(novoJogo.DataJogo, novoJogo.QtdPontos);

            _mockJogoRepository.Verify(v => v.AddJogo(It.IsAny <JogoBasquete>()), Times.Once);

            Assert.AreEqual(expectResult.Message, result.Message);
            Assert.AreEqual(expectResult.IsSuccess, result.IsSuccess);
        }
        public void Domain_Deve_Retornar_Resultados_Dos_Jogos_Com_Sucesso_Se_Lista_Vazia()
        {
            var expectRepositoryResult = new ResultBag <IEnumerable <JogoBasquete> >(true, new List <JogoBasquete>());
            var expectServiceResult    = new ResultBag <ResultadoJogos>(expectRepositoryResult.Message, expectRepositoryResult.IsSuccess, new ResultadoJogos());

            _mockJogoRepository.Setup(s => s.GetJogos()).Returns(expectRepositoryResult);

            var jogoService = new JogoService(_mockJogoRepository.Object);
            var result      = jogoService.GetResultadoJogos();

            _mockJogoRepository.Verify(v => v.GetJogos(), Times.Once);

            Assert.AreEqual(expectServiceResult.Message, result.Message);
            Assert.AreEqual(expectServiceResult.IsSuccess, result.IsSuccess);
            Assert.AreEqual(expectRepositoryResult.Data, result.Data.JogosBasquete);
        }
        public void Domain_Deve_Retornar_Resultados_Dos_Jogos_Com_Erro()
        {
            var expectRepositoryResult = new ResultBag <IEnumerable <JogoBasquete> >("Erro ao retornar jogos!", false, new List <JogoBasquete>());

            _mockJogoRepository.Setup(s => s.GetJogos()).Returns(expectRepositoryResult);

            var jogoService = new JogoService(_mockJogoRepository.Object);
            var result      = jogoService.GetResultadoJogos();

            _mockJogoRepository.Verify(v => v.GetJogos(), Times.Once);

            Assert.AreEqual(expectRepositoryResult.Message, result.Message);
            Assert.AreEqual(expectRepositoryResult.IsSuccess, result.IsSuccess);
            Assert.IsFalse(result.Data.JogosBasquete.Any());
            Assert.AreEqual(0, result.Data.TotalPontos);
            Assert.AreEqual(0, result.Data.TotalJogos);
        }
Beispiel #9
0
        public ActionResult Verificar(FormCollection collection)
        {
            try
            {
                Crime crimeSorteado = (Crime)Session["Crime"];

                //ViewBag.CrimeSorteado = String.Concat(crimeSorteado.Suspeito.Nome, "-", crimeSorteado.Local.Nome, "-", crimeSorteado.Arma.Nome);

                int suspeito = int.Parse(collection["Suspeito"]);
                int arma     = int.Parse(collection["Arma"]);
                int local    = int.Parse(collection["Local"]);

                JogoService service   = new JogoService((Crime)Session["Crime"]);
                int         resultado = service.VerificarTeoria(suspeito, arma, local);

                switch (resultado)
                {
                case 1:
                    ViewBag.Mensagem = "O assassino está incorreto";
                    break;

                case 2:
                    ViewBag.Mensagem = "O local está incorreto";
                    break;

                case 3:
                    ViewBag.Mensagem = "A arma está incorreta";
                    break;

                default:
                    return(RedirectToAction("CasoSolucionado"));
                }

                ViewBag.Resultado = resultado;

                this.CarregarDropDownList();

                return(View("Index"));
            }
            catch {
                return(RedirectToAction("Index"));
            }
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            IList <Jogo> jogos = new List <Jogo>();

            Console.WriteLine("Insira um placar ou digite 'sair'");
            var opcao  = Console.ReadLine();
            var placar = 0;

            while (opcao != "sair" && int.TryParse(opcao, out placar))
            {
                jogos.Add(new Jogo((jogos.Count + 1), placar));
                Console.WriteLine("Insira um placar ou digite 'sair'");
                opcao = Console.ReadLine();
            }

            Console.WriteLine("| Jogo | Placar | Minimo | Maximo | Quebra recorde min | Quebra recorde Max |");
            var viewModels = JogoService.CalcularJogos(jogos);

            foreach (var viewModel in viewModels)
            {
                Console.WriteLine("| " + viewModel.Id + " | " + viewModel.Placar + " | " + viewModel.MenorPlacar + " | " + viewModel.MaiorPlacar + " | " + viewModel.QuebraRecordeMin + " | " + viewModel.QuebraRecordeMax + " | ");
            }
        }
Beispiel #11
0
        public void deve_calcular_jogos()
        {
            var jogoA = new Jogo(1, 12);
            var jogoB = new Jogo(2, 24);
            var jogoC = new Jogo(3, 10);
            var jogoD = new Jogo(4, 25);

            var jogosCalculados = JogoService.CalcularJogos(new[] { jogoA, jogoB, jogoC, jogoD });

            Assert.Equal(1, jogosCalculados[0].Id);
            Assert.Equal(12, jogosCalculados[0].Placar);
            Assert.Equal(12, jogosCalculados[0].MenorPlacar);
            Assert.Equal(12, jogosCalculados[0].MaiorPlacar);
            Assert.Equal(0, jogosCalculados[0].QuebraRecordeMin);
            Assert.Equal(0, jogosCalculados[0].QuebraRecordeMax);

            Assert.Equal(2, jogosCalculados[1].Id);
            Assert.Equal(24, jogosCalculados[1].Placar);
            Assert.Equal(12, jogosCalculados[1].MenorPlacar);
            Assert.Equal(24, jogosCalculados[1].MaiorPlacar);
            Assert.Equal(0, jogosCalculados[1].QuebraRecordeMin);
            Assert.Equal(1, jogosCalculados[1].QuebraRecordeMax);

            Assert.Equal(3, jogosCalculados[2].Id);
            Assert.Equal(10, jogosCalculados[2].Placar);
            Assert.Equal(10, jogosCalculados[2].MenorPlacar);
            Assert.Equal(24, jogosCalculados[2].MaiorPlacar);
            Assert.Equal(1, jogosCalculados[2].QuebraRecordeMin);
            Assert.Equal(1, jogosCalculados[2].QuebraRecordeMax);

            Assert.Equal(4, jogosCalculados[3].Id);
            Assert.Equal(25, jogosCalculados[3].Placar);
            Assert.Equal(10, jogosCalculados[3].MenorPlacar);
            Assert.Equal(25, jogosCalculados[3].MaiorPlacar);
            Assert.Equal(1, jogosCalculados[3].QuebraRecordeMin);
            Assert.Equal(2, jogosCalculados[3].QuebraRecordeMax);
        }
Beispiel #12
0
        /*
         * public ProdutosController(AtividadeAula10Context context)
         * {
         *  _context = context;
         * }
         */

        public ProdutosController(JogoService jogoService, CategoriaService categoriaService)
        {
            _jogoService      = jogoService;
            _categoriaService = categoriaService;
        }
Beispiel #13
0
        public void CarregarListaJogos()
        {
            JogoService service = new JogoService();

            dgJogos.DataSource = service.ObterJogosCadastrados();
        }
Beispiel #14
0
 public JogosController(JogoService jogoService)
 {
     this.jogoService = jogoService;
 }
Beispiel #15
0
 public JogoServiceTests()
 {
     jogoService = new JogoService(new Mock <IJogoRepository>().Object, new Mock <IMapper>().Object, new Mock <IUserRepository>().Object);
 }
Beispiel #16
0
 public JogosController(JogoService jogoService)
 {
     _jogoService = jogoService;
 }
Beispiel #17
0
 private void InicializaConexao()
 {
     TConexao.Open();
     _service = new JogoService(TConexao.unitofWork, TConexao.context);
 }
Beispiel #18
0
        static void Main(string[] args)
        {
            ForcaContext   FContext       = new ForcaContext();
            PalavraService pServiceInicio = new PalavraService(FContext);

            //Buscar palavra aleatoria
            Palavra p = pServiceInicio.BuscarAleatorio();

            PalavraService pService = new PalavraService(FContext, p);

            //Se nao tiver nada no banco, popula com o palavras.json
            pService.PopulaDatabase();

            //Instancia o Jogo
            Jogo j = new Jogo(6, p);


            //Salva Jogo no banco
            JogoService jService = new JogoService(FContext, j);
            int         retorno  = jService.Cadastrar();


            int tentativa = 1;

            //Executa um loop para contar as tentativas
            while ((j.NumChance - j.NumTentativa) > 0)
            {
                //Exibe a dica, nº de palpites restantes e as lacunas
                Console.WriteLine("\nDica:" + p.Dica);

                Console.Write("Nº de Tentativas: ");
                Console.BackgroundColor = ConsoleColor.Yellow;
                Console.ForegroundColor = ConsoleColor.Black;
                Console.WriteLine(j.NumChance - j.NumTentativa);
                Console.ResetColor();

                //Se for a primeira rodada
                if (tentativa == 1)
                {
                    Console.WriteLine(pService.ExibeLacunas(pService.GeraLacunas()));
                }
                else
                {
                    Console.Write("Letras Utilizadas:");
                    Console.BackgroundColor = ConsoleColor.Gray;
                    Console.ForegroundColor = ConsoleColor.Black;
                    pService.ExibirTentivas().ForEach(x =>
                                                      Console.Write(x + " ")
                                                      );
                    Console.WriteLine("");
                    Console.ResetColor();
                }

                //Exibe a msg pro usuario tentar
                Console.Write("Escolha uma letra:");

                string sLetra = Console.ReadLine();
                char   letra  = Char.MinValue;
                if (sLetra != "")
                {
                    letra = sLetra.ToCharArray()[0];
                }
                else
                {
                    Console.WriteLine("Insira alguma letra!");
                }

                //Salva palpite no banco
                Palpite        palpite        = new Palpite(letra.ToString(), j);
                PalpiteService palpiteService = new PalpiteService(FContext, palpite);
                palpiteService.Cadastrar();

                bool acertou = pService.VerificaAcerto(letra);



                //Se acertou, renderiza novas lacunas
                pService.GeraLacunas(letra);

                //Se errado, Adiciona uma tentativa
                if (!acertou)
                {
                    jService.AdicionarTentativa();
                }

                Console.WriteLine(pService.ExibeLacunas(pService.PalavraParcial));

                if (pService.VerificaVencedor())
                {
                    Console.BackgroundColor = ConsoleColor.Green;
                    Console.ForegroundColor = ConsoleColor.Black;
                    Console.WriteLine("Você Venceu! A palavra é " + pService._Palavra.Termo);

                    //Salva vitoria no banco
                    j.Vitoria      = true;
                    j.NumTentativa = tentativa;

                    jService.Cadastrar();
                    Console.ReadKey();
                    return;
                }

                tentativa++;
            }

            Console.BackgroundColor = ConsoleColor.Red;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.WriteLine("Você Perdeu! A palavra era " + pService._Palavra.Termo);


            Console.ReadKey();
        }
Beispiel #19
0
 public JogoController(JogoService service)
 {
     this.service = service;
 }
Beispiel #20
0
 public void TestMethod1()
 {
     var service = new JogoService();
     var result  = service.GetJogos();
 }