Example #1
0
 public DoWait(GenericStep _step)
     : base()
 {
     waitTimer = new System.Timers.Timer();
     WaitStep  = new GenericWaitStep();
     WaitStep  = (GenericWaitStep)_step;
     timeOut   = WaitStep.TimeOut;
 }
Example #2
0
 public DoCall(GenericStep _step)
     : base()
 {
     callStep = new GenericCallStep();
     callStep = (GenericCallStep)_step;
     timeOut  = callStep.TimeOut;
     Console.WriteLine("Test " + ((eConf.SipConfig)EConfPlayer.Instance._Terminal.SipConfig).AnonymousCall);
 }
Example #3
0
 public void Max_Restarts()
 {
     var step1 = new GenericStep();
     Instance.AddLevel(branch => {
                           branch.AddStep(step1);
                           branch.Restart(3);
                       }).Execute();
     Assert.AreEqual(3, step1.ExecutedCount);
 }
Example #4
0
        private void _ScenarioEvents_NewStep(Object sender, EventArgs e)
        {
            GenericStep newStep     = (CommonProject.Scenario.Datas.GenericStep)sender;
            TreeNode    newTreeNode = new TreeNode(newStep.NumStep + 1 + "- " + ((StepsName)newStep.NameId).ToString(), 2, 2);

            newTreeNode.Name             = newStep.NumStep.ToString();
            newTreeNode.ContextMenuStrip = ActionMenuStrip;
            newTreeNode.Tag = newStep;
            solutionTreeNode.Nodes[MainEntry.scenarioSolution.CurrentScenario.Id].Nodes[0].Nodes.Add(newTreeNode);
        }
Example #5
0
        public void Max_Restarts()
        {
            var step1 = new GenericStep();

            Instance.AddLevel(branch => {
                branch.AddStep(step1);
                branch.Restart(3);
            }).Execute();
            Assert.AreEqual(3, step1.ExecutedCount);
        }
Example #6
0
        public void TypeFactory_Only_Invoked_When_Step_Executed()
        {
            var step = new GenericStep();

            var typeFactory = Mock.Of <ITypeFactory>(tf => tf.Create <GenericStep>() == step);

            Instance.WithTypeFactory(typeFactory).AddStep <GenericStep>().Execute();

            Assert.IsTrue(step.Executed);
        }
Example #7
0
 public void Add_Two_Instance_To_Workflow_Make_Sure_Executed()
 {
     var step1 = new GenericStep();
     var step2 = new GenericStep();
     Instance
         .AddStep(step1)
         .AddStep(step2)
         .Execute();
     Assert.IsTrue(step1.Executed);
     Assert.IsTrue(step2.Executed);
 }
Example #8
0
        private void DisplayResult(ScenarioResult _result)
        {
            listView1.Items.Clear();

            result = _result;

            Scenario.Datas.Scenario scenario = new Scenario.Datas.Scenario();
            scenario = MainEntry.scenarioSolution.Scenarios[result.IdScenario];

            scenarioNameLabel.Text = scenario.Name;
            dateLabel.Text         = result.BeginTime.ToString();
            if (result.HasCrashed)
            {
                generalResultLabel.Text = "Echec de la lecture du scenario";
            }
            else
            {
                generalResultLabel.Text = "Lecture terminée avec succés";
            }

            numberStepPlayedLabel.Text = result.StepsResults.Length.ToString();

            foreach (StepResult stepResult in result.StepsResults)
            {
                //Récupération du step associé
                GenericStep step = scenario.Steps[stepResult.NumStep];

                ListViewItem item1 = new ListViewItem("", Convert.ToInt16(stepResult.Status));
                item1.SubItems.Add(((StepsName)stepResult.NameId).ToString());
                item1.SubItems.Add(step.TesterSource + "   --->   " + step.TesterDestination);
                item1.SubItems.Add(stepResult.Msg);
                item1.Name = step.NumStep.ToString();

                //Ajout du step
                listView1.Items.Add(item1);
            }
            if (result.StepsResults.Length != 0)
            {
                steplabelDesc.Text = "n°" + (result.StepsResults[0].NumStep + 1) + ": " + ((StepsName)result.StepsResults[0].NameId).ToString();


                foreach (String currentMsg in result.StepsResults[0].TestersResults[0].Msg)
                {
                    logsSource.Text += "Log: " + currentMsg + System.Environment.NewLine;
                }

                foreach (String currentMsg in result.StepsResults[0].TestersResults[1].Msg)
                {
                    logsDestination.Text += "Log: " + currentMsg + System.Environment.NewLine;
                }
            }

            CommentsTextBox.Text = result.Comments;
        }
Example #9
0
 public void When()
 {
     var step2 = new GenericStep();
     var step3 = new GenericStep();
     Instance.AddStep<GenericStep, bool>(branch => {
                                             branch.When(true).AddStep(step2);
                                             branch.When(false).AddStep(step3);
                                         }).Execute();
     Assert.IsTrue(step2.Executed);
     Assert.IsFalse(step3.Executed);
 }
Example #10
0
        public void Add_Two_Instance_To_Workflow_Make_Sure_Executed()
        {
            var step1 = new GenericStep();
            var step2 = new GenericStep();

            Instance
            .AddStep(step1)
            .AddStep(step2)
            .Execute();
            Assert.IsTrue(step1.Executed);
            Assert.IsTrue(step2.Executed);
        }
Example #11
0
        /// <summary>
        /// Intervertit l'ordre de deux steps du scénario
        /// <summary>
        public void InvertTwoSteps(int _index1, int _index2)
        {
            GenericStep tempStep = new GenericStep();

            tempStep = listSteps[_index1];

            listSteps[_index1]         = listSteps[_index2];
            listSteps[_index1].NumStep = Convert.ToInt16(_index1);

            listSteps[_index2]         = tempStep;
            listSteps[_index2].NumStep = Convert.ToInt16(_index2);
        }
Example #12
0
        public void When()
        {
            var step2 = new GenericStep();
            var step3 = new GenericStep();

            Instance.AddStep <GenericStep, bool>(branch => {
                branch.When(true).AddStep(step2);
                branch.When(false).AddStep(step3);
            }).Execute();
            Assert.IsTrue(step2.Executed);
            Assert.IsFalse(step3.Executed);
        }
Example #13
0
        public void Cancel_Make_Sure_Following_Steps_Not_Executed()
        {
            Task.Factory.StartNew(() => {
                Thread.Sleep(100);
                Instance.Cancel();
            });

            var instance = new GenericStep();

            Instance.AddStep(new CancelableStep()).AddStep(instance).Execute();

            Assert.IsFalse(instance.Executed);
        }
Example #14
0
        public void Stop()
        {
            var step = new GenericStep();
            var subStep1 = new GenericStep();
            var subStep2 = new GenericStep();
            Instance.AddStep<GenericStep, bool>(step, branch => {
                branch.Stop();
                branch.AddStep(subStep1);
            }).AddStep(subStep2).Execute();

            Assert.IsTrue(step.Executed);
            Assert.IsFalse(subStep1.Executed);
            Assert.IsFalse(subStep2.Executed);
        }
Example #15
0
        public void Break_Out_Of_Level()
        {
            var subStep1 = new GenericStep();
            var subStep2 = new GenericStep();
            Instance.AddLevel(branch => {
                                  branch.AddStep(subStep1);
                                  branch.Break(2);
                              })
                .AddStep(subStep2)
                .Execute();

            Assert.IsTrue(subStep1.Executed);
            Assert.IsFalse(subStep2.Executed);
        }
Example #16
0
        public void Stop()
        {
            var step     = new GenericStep();
            var subStep1 = new GenericStep();
            var subStep2 = new GenericStep();

            Instance.AddStep <GenericStep, bool>(step, branch => {
                branch.Stop();
                branch.AddStep(subStep1);
            }).AddStep(subStep2).Execute();

            Assert.IsTrue(step.Executed);
            Assert.IsFalse(subStep1.Executed);
            Assert.IsFalse(subStep2.Executed);
        }
Example #17
0
        public void Break_Out_Of_Level()
        {
            var subStep1 = new GenericStep();
            var subStep2 = new GenericStep();

            Instance.AddLevel(branch => {
                branch.AddStep(subStep1);
                branch.Break(2);
            })
            .AddStep(subStep2)
            .Execute();

            Assert.IsTrue(subStep1.Executed);
            Assert.IsFalse(subStep2.Executed);
        }
Example #18
0
        public ReceiveCall(GenericStep _step)
            : base()
        {
            callStep = new GenericCallStep();
            callStep = (GenericCallStep)_step;
            timeOut  = callStep.TimeOut;

            timeOut += 10000;
            Trace.WriteLine(timeOut.ToString());

            EConfPlayer.Instance.ResetAllCodecs();
            EConfPlayer.Instance.ActivateCodec(eConf.eCodecType.eCODEC_AUDIOG711);
            EConfPlayer.Instance.ActivateCodec(eConf.eCodecType.eCODEC_AUDIORFC2833);
            EConfPlayer.Instance.ActivateCodec(eConf.eCodecType.eCODEC_AUDIOG722);
            Console.WriteLine("Test " + ((eConf.SipConfig)EConfPlayer.Instance._Terminal.SipConfig).AnonymousCall);
            Console.WriteLine("Test1 " + ((eConf.SipConfig)EConfPlayer.Instance._Terminal.SipConfig).CallInfo);
            Console.WriteLine("Test2 " + ((eConf.SipConfig)EConfPlayer.Instance._Terminal.SipConfig).DisplayName);
            Console.WriteLine("Test1 " + ((eConf.SipConfig)EConfPlayer.Instance._Terminal.SipConfig).AllowPresence);
        }
Example #19
0
        public void PlayScenario()
        {
            wait = new ManualResetEvent(false);

            //On s'enregistre à lévénement reception d'un fichier scenario
            MainEntry._serverEvent.ScenarioReceiveEvent += new ScenarioReceiveHandler(OnReceiveScenario);

            Trace.WriteDebug("Attente");
            //On attend ....
            wait.WaitOne();

            //On se désenregistre à lévénement reception d'un fichier scenario
            MainEntry._serverEvent.ScenarioReceiveEvent -= new ScenarioReceiveHandler(OnReceiveScenario);

            if (!isCrashed)
            {
                //Enregistrement à l'événement de recetion de l'ordre LoadScenario
                MainEntry._serverEvent.LoadScenarioEvent += new LoadScenarioHandler(OnLoadScenarioOrder);


                //On attend ....
                Trace.WriteDebug("Attente1");
                wait.Reset();
                wait.WaitOne();

                //On se désenregistre à l'événement de recetion de l'ordre LoadScenario
                MainEntry._serverEvent.LoadScenarioEvent -= new LoadScenarioHandler(OnLoadScenarioOrder);
            }

            if (!isCrashed)
            {
                if (ReadXMLScenario(scenarioDatas))
                {
                    Trace.WriteInfo("lecture du scenario OK");
                }
                else
                {
                    isCrashed = true;
                    Trace.WriteError("lecture du scenario Impossible KO");
                }

                //Enregistrement à l'événement de recetion de l'ordre PlayStep
                MainEntry._serverEvent.PlayStepEvent += new PlayStepHandler(OnPlayStepOrder);

                while (!isCrashed)
                {
                    //On attend...
                    Trace.WriteDebug("Attente2");
                    wait.Reset();
                    wait.WaitOne();
                  
                    if (!isCrashed)
                    {
                        //Lecture du Step                
                        stepToPlay = new GenericStep();
                        stepToPlay = scenarioToPlay.Steps[IdOfPlayingStep];
                        PlayStep();
                    }
                }

                //désenregistrement à l'événement de recetion de l'ordre PlayStep
                MainEntry._serverEvent.PlayStepEvent -= new PlayStepHandler(OnPlayStepOrder);                
            }
        }
Example #20
0
        /// <summary>
        /// Méthode qui exécute un step sur les testeurs sources et destinations
        /// </summary>
        private bool PlayStep(int num)
        {
            try
            {
                //On initialise les variables de travails
                testerSourceResults      = new GenericTesterResult();
                testerDestinationResults = new GenericTesterResult();

                stepResult = new StepResult();

                //On intialise le thread wait
                wait = new AutoResetEvent(false);

                //On déclare un nouveau Step contenant le step num
                GenericStep step = scenarioToPlay.Steps[num];

                //On enregistre les noms des testers source et destination
                testerDestinationName = step.TesterDestination;
                testerSourceName      = step.TesterSource;

                //on récupére l'identifiant du testeur source et destionation
                int idTesterSource      = MainEntry.listTesters.GetIdFromName(step.TesterSource);
                int idTesterDestination = MainEntry.listTesters.GetIdFromName(step.TesterDestination);

                //On s'enregistre à l'évenement OnReceiveStepResult
                MainEntry._TcpEvents.StepResultReceiveEvent += new CommonProject.Communication.StepResultReceiveHandler(OnReceiveStepResults);

                //On charge un timer qui déclenchera un timeOut au bout d'un temps données
                //sti.Handle = ThreadPool.RegisterWaitForSingleObject(wait, new WaitOrTimerCallback(OnTimeOut), sti, step.TimeOut, true);

                //Envoi de l'ordre d'exécuter le step
                MainEntry.listTesters.Tester[idTesterSource].PlayStep(num);
                MainEntry.listTesters.Tester[idTesterDestination].PlayStep(num);

                //Attente des résultat de ce Step exécutée par les deux testeurs
                wait.WaitOne();
                wait.Reset();
                wait.WaitOne();
                wait.Reset();

                MainEntry._TcpEvents.StepResultReceiveEvent -= new CommonProject.Communication.StepResultReceiveHandler(OnReceiveStepResults);

                //On instancie StepResult avec les résultat des actions efectué par les testeurs
                stepResult.NumStep = step.NumStep;
                stepResult.NameId  = step.NameId;
                stepResult.NameId  = step.NameId;
                stepResult.Status  = TestStatus.Success;
                List <GenericTesterResult> tempList = new List <GenericTesterResult>(2);
                tempList.Add(testerSourceResults);
                tempList.Add(testerDestinationResults);
                stepResult.TestersResults = tempList.ToArray();

                Trace.WriteLine("Début de l'analyse des résultats");

                foreach (GenericTesterResult current in stepResult.TestersResults)
                {
                    if (current.Status == TestStatus.Failed)
                    {
                        stepResult.Status = TestStatus.Failed;
                        stepResult.Msg    = "La lecture du step a échoué";
                    }
                    else if (current.Status == TestStatus.TimeOut)
                    {
                        stepResult.Status = TestStatus.TimeOut;
                        stepResult.Msg    = "Un timeOut s'est déclenché";
                    }
                    else
                    {
                        stepResult.Msg = "Step terminé avec succès";
                    }
                }

                //Test de vérification des DTMF reçus et envoyé
                if (stepResult.NameId == (int)StepsName.DTMF && stepResult.Status == TestStatus.Success)
                {
                    if (((GenericDTMFResult)testerSourceResults.Datas).DTMF != ((GenericDTMFResult)testerDestinationResults.Datas).DTMF)
                    {
                        stepResult.Status = TestStatus.Failed;
                        stepResult.Msg    = "Le DTMF reçu ne correspond pas au DTMF envoyé";
                    }
                }


                if (stepResult.NameId == (int)StepsName.Appel)
                {
                    Datas.Steps.CallStep callStep = (Datas.Steps.CallStep)step;

                    if (callStep.CallerIdentitie)
                    {
                        if (((GenericCallResult)testerDestinationResults.Datas).CallerName == "Anonymous")
                        {
                            stepResult.Status = TestStatus.Failed;
                            if (callStep.CallMode == CallMode.Normal)
                            {
                                stepResult.Msg = "L'appel en mode \"présentation du numéro\" a échoué";
                            }
                            else
                            {
                                stepResult.Msg = "L'appel n'a pas été reçu en mode OIP";
                            }
                        }
                    }
                    else
                    {
                        if (((GenericCallResult)testerDestinationResults.Datas).CallerName != "Anonymous")
                        {
                            stepResult.Status = TestStatus.Failed;
                            if (callStep.CallMode == CallMode.Normal)
                            {
                                stepResult.Msg = "L'appel a été reçu en mode OIP";
                            }
                            else
                            {
                                stepResult.Msg = "L'appel en mode OIR a échoué";
                            }
                        }
                    }
                }
                return(true);

                /*
                 * //Analyse du résultat pour identifier un échec fatal
                 * if (stepResult.Status == TestStatus.Failed && stepResult.NameId == (int)StepsName.Appel)
                 * {   //Echec Fatal
                 *  return false;
                 * }
                 * else
                 * {
                 *  return true;
                 * }  */
            }
            catch (Exception e)
            {
                Trace.WriteDebug("Erreur PLAYSTEP KO");
                stepResult.Msg    = "Erreur générale - L'appel n'a pas abouti";
                stepResult.Status = TestStatus.Failed;
                //Echec Fatal
                return(false);
            }
        }
Example #21
0
        public void TypeFactory_Only_Invoked_When_Step_Executed()
        {
            var step = new GenericStep();

            var typeFactory = Mock.Of<ITypeFactory>(tf => tf.Create<GenericStep>() == step);
            Instance.WithTypeFactory(typeFactory).AddStep<GenericStep>().Execute();

            Assert.IsTrue(step.Executed);
        }
Example #22
0
 public void Add_Steps_While_Executing()
 {
     var step = new GenericStep();
     Instance.AddLevel(level => Instance.AddStep(step)).Execute();
     Assert.IsTrue(step.Executed);
 }
Example #23
0
 public WorkFlowStep()
 {
     _step = new GenericStep();
 }
Example #24
0
        public void Cancel_Make_Sure_Following_Steps_Not_Executed()
        {
            Task.Factory.StartNew(() => {
                Thread.Sleep(100);
                Instance.Cancel();
            });

            var instance = new GenericStep();
            Instance.AddStep(new CancelableStep()).AddStep(instance).Execute();

            Assert.IsFalse(instance.Executed);
        }
Example #25
0
 /// <summary>
 /// Ajoute un step au scénario
 /// <summary>
 public void AddStep(GenericStep value)
 {
     value.NumStep = (short)this.listSteps.Count;
     this.listSteps.Add(value);
     MainEntry._ScenarioEvents.OnNewStep(value, null);
 }