Esempio n. 1
0
 public void Pegar_instancia_valida()
 {
     Assert.NotNull(FabricaCalculo.Crie(EnumFolhaDePagamento.Mensal, DateTime.Now));
     Assert.IsType <CalculoFolhaMensal>(FabricaCalculo.Crie(EnumFolhaDePagamento.Mensal, DateTime.Now));
     Assert.NotNull(FabricaCalculo.Crie(EnumFolhaDePagamento.Ferias, DateTime.Now));
     Assert.IsType <CalculoFolhaFerias>(FabricaCalculo.Crie(EnumFolhaDePagamento.Ferias, DateTime.Now));
     Assert.Throws <ArgumentException>(() => FabricaCalculo.Crie((EnumFolhaDePagamento)3, DateTime.Now));
 }
        static void Main(string[] args)
        {
            //CRIA O BAMCO EM MEMORIA
            BancoEmMemoria.CrieTabela(typeof(TabelaDoEstacionamento));

            //ADICIONA VEICULOS
            var estacionamento = new List <Veiculo>
            {
                new Carro("Carro", "NBK-0908", DateTime.Now),
                new Moto("Moto", "JKW-8756", DateTime.Now),
                new Carro("Carro", "JBL-5784", DateTime.Now),
                new Camionete("Camionete", "XYZ-7543", DateTime.Now),
                new Camionete("Camionete", "XYZ-7543", DateTime.Now),
                new Camionete("Camionete", "XYZ-7543", DateTime.Now),
                new Camionete("Camionete", "XYZ-7543", DateTime.Now),
                new Moto("Moto", "PQW-6789", new DateTime(2019, 08, 21, 10, 0, 0)),
                new Moto("Moto", "PFF-1245", DateTime.Now),
                new Camionete("Camionete", "ZDF-9987", DateTime.Now),
                new Carro("Carro", "NKZ-8760", new DateTime(2019, 08, 17, 14, 0, 0)),
                new Camionete("Camionete", "RNI-5678", new DateTime(2019, 08, 17, 7, 0, 0)),
                new Carro("Carro", "ZXC-5673", new DateTime(2019, 08, 21, 10, 0, 0))
            };

            //REALIZA OS CALCULOS REFERENTE A CADA VEICULO
            estacionamento.ForEach(x => FabricaCalculo.Calcule(x));

            //FAZ SELECT NA TABELA (RECEBE OBJECT E CONVERTE PARA TIPO TabelaDoEstacionamento
            var selectAll            = BancoEmMemoria.Select(typeof(TabelaDoEstacionamento));
            var tabelaEstacionamento = selectAll.ToList().ConvertAll <TabelaDoEstacionamento>(x => x as TabelaDoEstacionamento);

            Console.WriteLine("\n\n===================================================\n\n");
            Console.WriteLine("              RELATÓRIOS DO ESTACIONAMENTO                  ");
            Console.WriteLine("\n\n===================================================\n\n");

//          //SELECIONAR PLACAS POR DATAS
            DateTime data = new DateTime(2019, 08, 17);

            var selectPlacas = Relatorio.SelectData(tabelaEstacionamento, data);

            Console.WriteLine("===================================================");
            Console.WriteLine("=====VEÍCULOS ESTACIONADOS NA DATA: " + data.ToShortDateString() + "=====");
            Console.WriteLine("===================================================");
            foreach (var item in selectPlacas)
            {
                Console.WriteLine("Data: " + data.ToShortDateString() + " Placa: " + item);
            }
            Console.WriteLine("===================================================\n\n");

//          //AGRUPADO POR TIPO E ORDENADO POR PLACA
            var listaAgrupada = Relatorio.AgrupadorTipo(tabelaEstacionamento);

            Console.WriteLine("===============================================");
            Console.WriteLine("==========VEÍCULOS AGRUPADOS POR TIPO==========");
            Console.WriteLine("===============================================");
            foreach (var item in listaAgrupada)
            {
                Console.WriteLine("Tipo: " + item.Tipo + " // " + " Placa: " + item.Placa);
            }
            Console.WriteLine("===============================================\n");

//          //TEMPO MEDIO POR TIPO
            Console.WriteLine("\n======================================");
            Console.WriteLine("=====MÉDIA DOS TIPOS DE VEÍCULOS======");
            Console.WriteLine("======================================");
            Relatorio.MediaTempo(tabelaEstacionamento);
            Console.WriteLine("======================================\n");

//          //QUANTIDADE DE VEICULOS AGRUPADAS POR DATA
            Console.WriteLine("\n===================================================");
            Console.WriteLine("=======QUANTIDADE DE VEÍCULOS POR DATA=============");
            Console.WriteLine("===================================================");
            Relatorio.QuantidadeVeiculos(tabelaEstacionamento);

//          //MOSTRA TODOS OS DADOS
            Console.WriteLine("\n\n===================================================\n\n");
            Console.WriteLine("               RELATÓRIO DOS VEÍCULOS                  ");
            Console.WriteLine("\n\n===================================================\n\n");

            tabelaEstacionamento.ForEach(v =>
            {
                Console.WriteLine("==================================================\n" +
                                  "Tipo: " + v.Tipo +
                                  "\nPlaca: " + v.Placa +
                                  "\nEntrada: " + v.Entrada +
                                  "\nSaida: " + v.Saida +
                                  "\nValor Pago: R$ " + v.ValorPago + " reais." +
                                  "\nTempo Estacionado: " + v.TempoEstacionado + " minutos." +
                                  "\n==================================================\n");
            });

            Console.Read();
        }