Exemplo n.º 1
0
        public void executar()
        {
            //Achar a Acao que está no passo

            Logger.escrever("Acao: " + acaoSelecionada.Nome + " " + acaoSelecionada.TelaPai.Nome + " " + acaoSelecionada.Id.ToString());

            if (!deveExecutar)
            {
                throw new Exception("A função não deve ser executada");
            }

            bool retorno;

            //Tratando Programação dentro da Grid
            string ParametroKeeper = Parametro;

            if (Parametro == null)
            {
                Parametro = "";
            }
            if (ParametroEhFuncao())
            {
                //é uma programação
                string funcao        = Parametro.Substring(1, Parametro.IndexOf("(") - 1);
                string parametroFunc = Parametro.Substring(Parametro.IndexOf("(") + 1, Parametro.Length - funcao.Length - 3);

                funcao = funcao.ToUpper();

                switch (funcao)
                {
                case "PARAMETRO":
                    this.Parametro = this.TestCaseParent.getPassoDoTestAtIndex(Convert.ToInt32(parametroFunc)).Parametro;
                    break;

                case "RETORNO":
                    //Recuperar Passo do Teste Específico do Caso de Teste do Qual esse Passo Pertence
                    this.Parametro = this.TestCaseParent.getPassoDoTestAtIndex(Convert.ToInt32(parametroFunc)).Retorno;
                    break;

                case "GERARCPF":
                    this.Parametro = Utils.GerarCpf();
                    break;

                case "DATAHOJE":
                    this.Parametro = Utils.dataHoje();
                    break;

                case "GERARCNS":
                    this.Parametro = Utils.geraCNS();
                    break;
                }
            }

            resultado = acaoSelecionada.Executar(Parametro);

            this.Retorno = resultado.retornoInformacao;

            //MessageBox.Show(resultado.passou.ToString() + resultado.retornoInformacao);
            //if (acaoSelecionada.acaoRetorno != null)
            //    this.Retorno = acaoSelecionada.acaoRetorno(Parametro);

            parametroComputado = Parametro;
            Parametro          = ParametroKeeper;


            if (deveFotografar)
            {
                CTF.inserirImagem(PrintUtils.takeSS());
            }
            if (resultado.passou == true)
            {
                //ok
                teveSucesso  = true;
                SituationImg = PassoDoTeste.IMG_APPR;
            }
            else
            {
                teveSucesso  = false;
                SituationImg = PassoDoTeste.IMG_ERRO;
                throw new Exception("Ação retornou FALSE (resultado esperado falhou).");
            }
        }