public void GivenLesVotesDesElecteurs(string nomScrutin, Table table)
        {
            var scrutin = StepHelpers.GetScrutin(nomScrutin);

            foreach (var v in table.Rows.GroupBy(r => r["Option"]))
            {
                var optionScrutin = scrutin.VotingProcessOption.First(o => o.Option.Name == v.Key);
                optionScrutin.Act = new List <Act>();

                var choice  = scrutin.VotingProcessMode.Choice.ToDictionary(c => c.Name);
                var options = scrutin.VotingProcessOption.Select(o => o.Option).ToDictionary(c => c.Name);

                foreach (var row in v)
                {
                    var acte = new Act()
                    {
                        Id       = StepHelpers.GetNextId(),
                        IdChoice = choice[row["Choice"]].Id,
                        IdVotingProcessOption = options[row["Option"]].Id,
                    };

                    optionScrutin.Act.Add(acte);
                }
            }
            ;
        }
        public void ThenLeResultatEstEnregistreEnBaseDeDonnees(Table table)
        {
            Result resultat = ScenarioContext.Current["ResultatBdd"] as Result;

            foreach (var row in table.Rows)
            {
                var scrutin = StepHelpers.GetScrutin(row["VotingProcess"]);
                Check.That(resultat.IdVotingProcess).IsEqualTo(scrutin.Id);
                Check.That(resultat.NbVoters).IsEqualTo(Convert.ToInt32(row["Nombre votants"]));

                if (row["Valide"].ToLower() == "oui")
                {
                    Check.That(resultat.IsValid).IsTrue();
                }
                else
                {
                    Check.That(resultat.IsValid).IsFalse();
                }

                if (row["Vainqueur"].ToLower() != "aucun")
                {
                    var vainqueur = scrutin.VotingProcessOption.Select(os => os.Option).First(o => o.Name == row["Vainqueur"]);
                    Check.That(resultat.IdWinningOption).IsEqualTo(vainqueur.Id);
                }
                else
                {
                    Check.That(resultat.IdWinningOption).IsNull();
                }

                var json = JsonConvert.SerializeObject(Resultat.IndividualResults);
                Check.That((resultat.ScoreDetail)).IsEqualTo(json);
            }
        }
Exemple #3
0
 private static VotingProcessOption CreateOptionScrutin(string optionName)
 => new VotingProcessOption
 {
     Id     = StepHelpers.GetNextId(),
     Option = new Option()
     {
         Id   = StepHelpers.GetNextId(),
         Name = optionName
     },
     Act = new List <Act>()
 };
        public void WhenJeClotureLe(string votingProcessName)
        {
            var scrutin = StepHelpers.GetScrutin(votingProcessName);

            try
            {
                StepHelpers.CloreScrutin(scrutin.Guid);
                Resultat = StepHelpers.GetResultatScrutin(scrutin.Guid) as ResultatMajoritaryJudgmentModel;
            }
            catch (Exception e)
            {
                ScenarioContext.Current["ExceptionMessage"] = e.Message;
            }
        }
 public void GivenLesChoixSuivants(Table table)
 {
     foreach (var scrutin in StepHelpers.GetAllScrutins())
     {
         foreach (var row in table.Rows)
         {
             scrutin.VotingProcessMode.Choice.Add(new Choice
             {
                 Id    = StepHelpers.GetNextId(),
                 Name  = row["Nom"],
                 Value = int.Parse(row["Valeur"])
             });
         }
     }
 }
 public void GivenUneListeDeScrutin(Table table)
 {
     foreach (var row in table.Rows)
     {
         var scrutin = new VotingProcess()
         {
             Id   = StepHelpers.GetNextId(),
             Name = row["VotingProcess"],
             VotingProcessMode = new VotingProcessMode
             {
                 Choice = new List <Choice>(),
                 Code   = "jugement-majoritaire"
             }
         };
         StepHelpers.AddScrutin(scrutin);
     }
 }
Exemple #7
0
        public void GivenLesOptionsSuivantesDuScrutin(string votingProcessName, Table table)
        {
            var votingProcess = StepHelpers.GetScrutin(votingProcessName);

            votingProcess.VotingProcessOption = table.Rows.Select(row => CreateOptionScrutin(row["Nom"])).ToList();
        }