protected AppendEntryBaseTest()
        {
            // Arrange  
            var mocker = new AutoMocker();

            ServerIdentifier = new ServerIdentifier();

            mocker.Use(ServerIdentifier);

            mocker.Setup<ISubject<AppendEntryMessage>>(p => p.Subscribe(It.IsAny<IObserver<AppendEntryMessage>>()))
                .Callback<IObserver<AppendEntryMessage>>((o) =>
                {
                    AppendEntryCallback = o;
                });
            AppendEntryCallback = mocker.Get<ISubject<AppendEntryMessage>>();

            AppendEntryResult = new Subject<AppendEntryResultMessage>();
            Election = new Election();
            LogReplication = new LogReplication();
            
            AppendEntry = new Rafting.AppendEntry(AppendEntryResult,
                mocker.Get<ISubject<AppendEntryMessage>>(),
                mocker.Get<IHartbeatTimer>(),
                LogReplication,
                Election,
                mocker.Get<ILoggerFactory>(),
                new RaftOptions(),
                mocker.Get<ServerIdentifier>(),
                null);
        }
        protected VoteReceivedBaseTests()
        {
            // Arrange
            var mocker = new AutoMocker();

            ServerIdentifier = new ServerIdentifier();

            mocker.Use(ServerIdentifier);

            mocker.Setup<ISubject<RequestVoteMessage>>(p => p.Subscribe(It.IsAny<IObserver<RequestVoteMessage>>()))
                .Callback<IObserver<RequestVoteMessage>>((o) =>
                {
                    RequestVoteCallback = o;
                });
            RequestVoteCallback = mocker.Get<ISubject<RequestVoteMessage>>();

            Election = new Election();

            Message = new RequestVoteResultMessage();

            mocker.Setup<ISubject<RequestVoteResultMessage>>(p => p.OnNext(It.IsAny<RequestVoteResultMessage>()))
                .Callback<RequestVoteResultMessage>((o) =>
                {
                    Message = o;
                });

            VoteReceived = new Rafting.VoteReceived(mocker.Get<ISubject<RequestVoteResultMessage>>(),
                mocker.Get<ServerIdentifier>(),
                mocker.Get<ISubject<RequestVoteMessage>>(),
                Election,
                mocker.Get<ILoggerFactory>(),
                new Nodes(),
                new RaftOptions(),
                mocker.Get<ILogReplication>());
        }
        public CandidateBaseTests()
        {
            var mocker = new AutoMocker();

            ServerIdentifier = new ServerIdentifier();
            mocker.Use(ServerIdentifier);


            Election = new Election();
            RequestVoteResult = new Subject<RequestVoteResultMessage>();
            RequestVote = new Subject<RequestVoteMessage>();
            MockVotingSystem = mocker.GetMock<IVotingSystem>();


            Candidate = new Rafting.States.Candidate(mocker.Get<ServerIdentifier>(),
                mocker.Get<IElectionTimer>(),
                RequestVote,
                RequestVoteResult,
                MockVotingSystem.Object,
                Election,
                mocker.Get<ILogReplication>(),
                mocker.Get<Nodes>(),
                mocker.Get<ILoggerFactory>(),
                new RaftOptions());
        }
 public void CreateElection(Election election)
 {
     _db.Execute(@"INSERT INTO dbo.elections (name, user_id)
                   VALUES (@Name, @UserId)",
         new
         {
             Name = election.Name,
             UserId = election.UserId
         });
 }
Exemple #5
0
 public HighAvailabilityModeSwitcher(SwitchToSlave switchToSlave, SwitchToMaster switchToMaster, Election election, ClusterMemberAvailability clusterMemberAvailability, ClusterClient clusterClient, System.Func <StoreId> storeIdSupplier, InstanceId instanceId, ComponentSwitcher componentSwitcher, DataSourceManager neoStoreDataSourceSupplier, LogService logService)
 {
     this._switchToSlave             = switchToSlave;
     this._switchToMaster            = switchToMaster;
     this._election                  = election;
     this._clusterMemberAvailability = clusterMemberAvailability;
     this._clusterClient             = clusterClient;
     this._storeIdSupplier           = storeIdSupplier;
     this._instanceId                = instanceId;
     this._componentSwitcher         = componentSwitcher;
     this._msgLog  = logService.GetInternalLog(this.GetType());
     this._userLog = logService.GetUserLog(this.GetType());
     this._neoStoreDataSourceSupplier = neoStoreDataSourceSupplier;
     this._haCommunicationLife        = new LifeSupport();
 }
        public ActionResult Nominees(int electionid = 0)
        {
            // check that election exists
            Election election = db.Elections.Find(electionid);

            if (election == null)
            {
                return(HttpNotFound());
            }

            ViewData["election"] = election;
            ViewData["nominees"] = ElectionTypeHelperFactory.Instance.getElecTypeEligChecker(election).vote_getAllNominees(election);

            return(View());
        }
        public async Task <IActionResult> DeleteElections(int?id)
        {
            if (id != null)
            {
                Election election = db.Elections.FirstOrDefault(p => p.Id == id);
                if (election != null)
                {
                    db.Elections.Remove(election);
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Elections"));
                }
            }
            return(NotFound());
        }
        public int deleteElection(int electionId)
        {
            Election election = getElectionById(electionId);

            if (election != null)
            {
                foreach (Candidate candidate in election.Candidates)
                {
                    electContext.Candidates.Remove(candidate);
                }
                electContext.Elections.Remove(election);
                electContext.SaveChanges();
            }
            return(electionId);
        }
        private static int GetAlarmThreshold(Election election)
        {
            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (election.State)
            {
            case ElectionState.Nominations:
                return(election.Nominations.AlarmThreshold);

            case ElectionState.Voting:
                return(election.Voting.AlarmThreshold);

            default:
                throw new Exception($"Election {election.Id} not in nominations or voting state. WTF?!");
            }
        }
        // GET: Elections/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Election election = db.Elections.Find(id);

            if (election == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CountryId = new SelectList(db.Countries, "CountryId", "CountryName", election.CountryId);
            return(PartialView(election));
        }
 private static IEnumerable <PositionEligibilityEntry> GeneratePositionEntriesForCouncil(
     Election election,
     IEnumerable <TimetableUserEntry> users // Not queryable as here we operate on things in memory
     )
 {
     return(users
            .SelectMany(user => election.Positions, Tuple.Create) // Cross join
            .Select(tuple => new PositionEligibilityEntry
     {
         Username = tuple.Item1.UserId,
         Position = tuple.Item2,
         CanNominate = true,
         CanVote = true
     }));
 }
        public async Task AddElection(Election election)
        {
            try
            {
                await _ctx.Elections.AddAsync(election);

                await _ctx.SaveChangesAsync();

                return;
            }
            catch (Exception ex)
            {
                _logger.LogInformation($"There was an error {ex.Message}");
            }
        }
 public IActionResult ConfirmDeleteElections(int?id)
 {
     if (id != null)
     {
         Election election = db.Elections.FirstOrDefault(p => p.Id == id);
         if (election != null)
         {
             if (election != null)
             {
                 return(View(election));
             }
         }
     }
     return(NotFound());
 }
Exemple #14
0
 /// <summary>
 /// Добавить выборы с опциями
 /// </summary>
 /// <param name="name">название голосования</param>
 /// <param name="start">дата начала голосования</param>
 /// <param name="end">дата окончания голосования</param>
 /// <param name="description">описание голосования</param>
 /// <param name="candidates">список опций</param>
 /// <returns>созданное голосование в случае успеха, иначе - null</returns>
 public static Election AddElectionWithCandidates(string name, DateTime start, DateTime end, string description, List <User> candidates)
 {
     if (GetElectionByName(name) != null)
     {
         return(null);
     }
     if (candidates == null || candidates.Count == 0)
     {
         return(null);
     }
     using (var db = new ElectionsDataBase())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 Election elections = new Election()
                 {
                     Name           = name,
                     DateStart      = start,
                     DateEnd        = end,
                     Description    = description,
                     Voting_type_id = 2 //Election
                 };
                 db.Elections.Add(elections);
                 db.SaveChanges();
                 foreach (var candidate in candidates)
                 {
                     db.ElectionOptions.Add(new ElectionOption()
                     {
                         Election_id = elections.Id, Option_id = candidate.Id
                     });
                     db.SaveChanges();
                 }
                 db.SaveChanges();
                 db.Blocks.Add(new Block(elections));
                 db.SaveChanges();
                 transaction.Commit();
                 return(elections);
             }
             catch (Exception)
             {
                 transaction.Rollback();
                 return(null);
             }
         }
     }
 }
        public static void Execute(int electionId, IJobCancellationToken cancellationToken)
        {
            using (var db = new VotingDbContext())
            {
                Election election = db.Elections.Find(electionId);
                if (election == null)
                {
                    throw new ArgumentOutOfRangeException(nameof(electionId), "No election with such id");
                }

                if (election.DisableAutomaticEligibility)
                {
                    // Nothing to do
                    return;
                }

                using (var timetable = new TimetableDbContext())
                {
                    IEnumerable <ElectionEligibilityEntry> electionEntries =
                        EligibilityGenerator.GenerateElectionEntries(election, timetable.Users);
                    cancellationToken.ThrowIfCancellationRequested();

                    IEnumerable <PositionEligibilityEntry> positionEntries =
                        EligibilityGenerator.GeneratePositionEntries(election, timetable.Users, db);
                    cancellationToken.ThrowIfCancellationRequested();

                    // Note that we cannot dispose the timetable db context here
                    // since the queries are only "planned" yet and not actually executed

                    // Save election entries, only ones that do not exist in database
                    AddNewEntries(
                        electionEntries, db.ElectionEligibilityEntries,
                        (entry, set) => set.Find(entry.Username, entry.Election.Id)
                        );

                    cancellationToken.ThrowIfCancellationRequested();

                    // Save position entries, only ones that do not exist in database
                    AddNewEntries(
                        positionEntries, db.PositionEligibilityEntries,
                        (entry, set) => set.Find(entry.Username, entry.Position.Id)
                        );

                    cancellationToken.ThrowIfCancellationRequested();
                    db.SaveChanges();
                }
            }
        }
Exemple #16
0
        public async Task <IActionResult> GetCandidatesList_byElectionId([FromBody] string electionId)
        {
            //this method is called using ajax calls
            //so if a business rule is not met we'll throw a businessException and catch it to create and internal server error and return its msg
            //as json



            try
            {
                if (String.IsNullOrEmpty(electionId))
                {
                    throw new BusinessException(_messagesLoclizer["electionId cannot be null."]);
                }
                Election e = _electionBusiness.GetById(Guid.Parse(electionId));
                if (e == null)
                {
                    throw new BusinessException(_messagesLoclizer["Election is not found."]);
                }

                //lets serialize the list of candidates of the election we've got and send it back as a reponse
                //note that I didn't retrieve candidates as they are, I selected only needed attributes bcuz when i tried serializing
                //candidates objects as they are I got this error "self referencing loop detected with type" it means json tried to serialize the candidate object
                //but it found that each candidate has an Election object, and this election object has a list of candidates and so on, so i excluded election
                //from the selection to avoid the infinite loop

                var candidates = _candidateBusiness.GetCandidate_byElection(e);
                if (candidates == null)
                {
                    throw new BusinessException(_messagesLoclizer["Candidates List not found."]);
                }

                var json = JsonConvert.SerializeObject(_candidateBusiness.ConvertCandidateList_ToCandidateViewModelList(candidates));
                return(Ok(json));
            }
            catch (BusinessException be)
            {
                //lets create an internal server error so that the response returned is an ERROR, and jQuery ajax will understand that.
                HttpContext.Response.StatusCode = 500;
                return(Json(new { Message = be.Message }));
            }
            catch (Exception E)
            {
                //lets create an internal server error so that the response returned is an ERROR, and jQuery ajax will understand that.
                HttpContext.Response.StatusCode = 500;
                return(Json(new { Message = E.Message }));
            }
        }
Exemple #17
0
 internal DummyDatabase(Election election)
 {
     Districts = new Dictionary <int, Dictionary <int, District> >()
     {
         {
             1, //Identificador de la elección
             new Dictionary <int, District>()
             {
                 { 1, new District(election, 1, ZARAGOZA, 7) },
                 { 2, new District(election, 2, HUESCA, 3) },
                 { 3, new District(election, 3, TERUEL, 3) },
                 { 4, new District(election, 4, MORDOR, 337) }
             }
         }
     };
 }
        public void should_not_create_candidates_when_password_is_incorrect()
        {
            // Dado / Setup
            var election   = new Election();
            var jose       = new Candidate("José", "111.111.111-11");
            var candidates = new List <Candidate> {
                jose
            };

            // Quando / Ação
            var created = election.CreateCandidates(candidates, "incorrect");

            // Deve / Asserções
            Assert.Empty(election.Candidates);
            Assert.False(created);
        }
Exemple #19
0
        public void should_not_generate_same_id_for_both_candidates()
        {
            var election   = new Election();
            var candidates = new List <Candidate> {
                new Candidate("José", "009.923.970-14"), new Candidate("Ana", "852.710.650-73")
            };

            election.CreateCandidates(candidates, "Pa$$w0rd");

            // Quando / Ação
            var candidateJose = election.Candidates.ElementAt(0).Id;
            var candidateAna  = election.Candidates.ElementAt(1).Id;

            // Deve / Asserções
            Assert.NotEqual(candidateAna, candidateJose);
        }
Exemple #20
0
 public IActionResult getElectionById([FromBody] GetElectionByIdFilter filter)
 {
     if (ModelState.IsValid)
     {
         if (UserUtils.isAdmin(filter.user, electContext))
         {
             Elections electionModel = new Elections(electContext);
             Election  election      = electionModel.getElectionById(filter.electionId);
             if (election != null)
             {
                 return(Ok(election));
             }
         }
     }
     return(BadRequest());
 }
Exemple #21
0
        public void should_return_false_when_the_password_is_wrong()
        {
            // Dado / Setup
            var election        = new Election();
            var rafael          = new Candidate("Rafael", "123.456.789.10");
            var candidatesInput = new List <Candidate> {
                rafael
            };

            // Quando / Ação
            bool result = election.CreateCandidates(candidatesInput, "WrongPassword123");

            // Deve / Asserções
            Assert.False(result);
            Assert.Empty(election.Candidates);
        }
        private Dictionary <string, Candidate> UploadCandidates(
            ModelContext modelContext,
            Election election,
            IEnumerable <string> candidateNames)
        {
            var result = new Dictionary <string, Candidate>();

            foreach (var candidateName in candidateNames)
            {
                var candidate = modelContext.Candidates.GetOrAdd(candidateName, election);

                result[candidateName] = candidate;
            }

            return(result);
        }
Exemple #23
0
        public ActionResult Create([Bind(Include = "pollCode,pollName,hostName,noOfContestants")] Election election)
        {
            if (ModelState.IsValid)
            {
                Session.Add("candy", election.noOfContestants);
                Session.Add("code", election.pollCode);
                Session.Add("electionName", election.pollName);

                election.hasEnded = 0;
                db.Elections.Add(election);
                db.SaveChanges();
                return(RedirectToAction("Create", "Contestants"));
            }

            return(View(election));
        }
Exemple #24
0
        public async Task <Election> Insert(IUnitOfWork uow, Election election)
        {
            Election result = null;

            try
            {
                result = await uow.Context.QuerySingleAsync <Election>(sql : "Election_Insert", param : SetParam(election),
                                                                       commandType : System.Data.CommandType.StoredProcedure, transaction : uow.Trans);
            }
            catch (Exception ex)
            {
                throw;
            }

            return(result);
        }
Exemple #25
0
        public void should_not_create_candidates_when_password_is_incorrect()
        {
            var election      = new Election();
            var candidateAna  = new Candidates("Ana", "154.585.256-58");
            var candidateJose = new Candidates("Jose", "145.845.848-47");

            var candidates = new List <Candidates>()
            {
                candidateAna, candidateJose
            };

            var created = election.CreateCandidates(candidates, "Incorrect");

            Assert.Null(election.Candidates);
            Assert.False(created);
        }
Exemple #26
0
        public void Should_Return_Second_Shuri_ID_Search_By_Her_CPF()
        {
            //Given
            var openElections         = new Election();
            var candidatesForElection = PreCandidatesFactory();
            var candidateShuriSecond  = new Candidate("Shuri", "145.098.756-98");

            candidatesForElection.Add(candidateShuriSecond);
            var subscribedForElection = openElections.CreateCandidates(candidatesForElection, "Pa$$w0rd");

            //When
            var shuriSegundaId = openElections.GetCandidateIdByCpf("145.098.756-98");

            //Then
            Assert.Equal(candidateShuriSecond.Id, shuriSegundaId);
        }
Exemple #27
0
        public void should_return_true_when_the_password_is_correct()
        {
            // Dado / Setup
            var election        = new Election();
            var rafael          = new Candidate("Rafael", "123.456.789.10");
            var candidatesInput = new List <Candidate> {
                rafael
            };

            // Quando / Ação
            bool result = election.CreateCandidates(candidatesInput, "Pa$$w0rd");

            // Deve / Asserções
            Assert.True(result);
            Assert.Equal(1, election.Candidates.Count);
        }
        private void PopulateElectionElectiveData(Election election)
        {
            var electionElectives = new HashSet <int>(election.Electives.Select(e => e.Id));
            var viewModel         = new List <AssignedElectiveData>();

            foreach (var elective in election.Electives)
            {
                viewModel.Add(new AssignedElectiveData
                {
                    ElectiveId = elective.Id,
                    Name       = elective.Name,
                    Assigned   = electionElectives.Contains(elective.Id)
                });
            }
            ViewBag.Electives = viewModel;
        }
Exemple #29
0
        public async Task <IActionResult> Votation(ElectionVotationViewModel electionVotationViewModel)
        {
            if (!HttpContext.Session.GetInt32(Configuration.Citizen).HasValue)
            {
                return(RedirectToAction(nameof(Index)));
            }
            Election election = await _electionService.GetElectionByConditionAsync(e => e.IsActive == true).Result.Include(e => e.ElectionPosition).ThenInclude(ep => ep.Position).FirstOrDefaultAsync();

            if (electionVotationViewModel.Id == 0)
            {
                electionVotationViewModel.Id   = election.Id;
                electionVotationViewModel.Name = election.Name;
            }
            electionVotationViewModel.Postions = election.ElectionPosition.Select(ep => ep.Position).ToList();
            return(View(electionVotationViewModel));
        }
Exemple #30
0
        public void Should_not_create_candidates_when_password_is_incorrect()
        {
            // Dado / Setup
            var election   = new Election();
            var Jose       = new Candidate("José", "895.456.214-78");
            var candidates = new List <Candidate> {
                Jose
            };

            // Quando / Ação
            var created = election.CreateCandidates(candidates, "senhaErrada");

            // Deve / Asserções
            Assert.Empty(election.Candidates);
            Assert.False(created);
        }
        public Election GetCurrentElection()
        {
            try
            {
                //declaring an expression that is special to Election objects
                //a current Election is the one that 'Date.Now' is between the startDate and the endDate(endDate = startDate + duration in days)
                Expression <Func <Election, bool> > expr = e => DateTime.Now.Date >= e.StartDate && DateTime.Now.Date.AddDays(-e.DurationInDays) <= e.StartDate;

                Election currentElection = GetAllFiltered(expr).FirstOrDefault();
                return(currentElection);
            }
            catch (Exception E)
            {
                throw E;
            }
        }
Exemple #32
0
    protected void ButtonSave_Click(object sender, EventArgs e)
    {
        Organization org      = Organization.PPSE;
        Election     election = Election.September2010;

        Ballot ballot = Ballot.FromIdentity((int)ViewState[this.ClientID + "SelectedBallot"]);

        ballot.ClearCandidates();

        ballot.DeliveryAddress = this.TextDeliveryAddress.Text;
        ballot.Count           = Int32.Parse(this.TextBallotCount.Text);

        string[] candidateNames = this.TextCandidates.Text.Split('\r', '\n');

        foreach (string candidateNameSource in candidateNames)
        {
            if (candidateNameSource.Trim().Length < 3)
            {
                continue;
            }

            int personId = 0;

            int idStartIndex = candidateNameSource.LastIndexOf("(#");

            if (idStartIndex > 0)
            {
                string identityString = candidateNameSource.Substring(idStartIndex + 2);
                int    idEndIndex     = identityString.IndexOf(")");

                identityString = identityString.Substring(0, idEndIndex);

                personId = Int32.Parse(identityString);
            }

            if (personId == 0)
            {
                personId = 1;
            }

            ballot.AddCandidate(Person.FromIdentity(personId));
        }

        PopulateCandidates();

        Page.ClientScript.RegisterStartupScript(typeof(Page), "OkMessage", @"alert ('Valsedel #" + ballot.Identity + " sparades.');", true);
    }
Exemple #33
0
        private void ChangeStateByUserAndRecord(Election election, ElectionState newState)
        {
            ElectionStateChange stateChange = new ElectionStateChange()
            {
                Election           = election,
                PreviousState      = election.State,
                TargetState        = newState,
                IsCausedByUser     = true,
                InstigatorUsername = User.Identity.GetUserId(),
                CompletedAt        = DateTime.Now
            };

            db.ElectionStateChanges.Add(stateChange);
            election.State = newState;

            AuditLogManager.RecordElectionStateChange(stateChange);
        }
Exemple #34
0
        public void should_create_candidates_when_password_is_correct()
        {
            var election   = new Election();
            var candidates = new List <Candidate> {
                new Candidate("José", "009.923.970-14"), new Candidate("Ana", "852.710.650-73")
            };

            var created = election.CreateCandidates(candidates, "Pa$$w0rd");

            var candidateJose = election.GetCandidateIdByName("José");
            var candidateAna  = election.GetCandidateIdByName("Ana");

            Assert.True(created);

            Assert.Equal(2, election.Candidates.Count);
            Assert.NotEqual(candidateJose, candidateAna);
        }
Exemple #35
0
 public void Start()
 {
     jsonString = Resources.Load<TextAsset>("EventConfigs").text;
     EventConfigs = JsonMapper.ToObject<LitJson.JsonData>(jsonString);
     election = GetComponent<Election>();
     EventPanel.SetActive(false);
 }
Exemple #36
0
 void Start()
 {
     normal = 1f;
     election = GetComponent<Election>();
     influence = GetComponent<Influence>();
     revolution = GetComponent<Revolution>();
     oppositionDelta = -1;
     netGrowth = 0;
     //		StartCoroutine(Run());
     prompt = false;
 }
Exemple #37
0
        public bool UpdateElectionSetup(Election election)
        {
            var result = _db.Execute(@"UPDATE elections
                                       SET name = @Name,
                                           max_votes = @MaxVotes,
                                           min_votes = @MinVotes,
                                           no_vote = @NoVote
                                       WHERE election_id = @ElectionId",
                new
                {
                    MaxVotes = election.MaxVotes,
                    MinVotes = election.MinVotes,
                    NoVote = election.NoVote,
                    ElectionId = election.ElectionId,
                    Name = election.Name
                });

            return result == 1;
        }
Exemple #38
0
        public JsonResult UpdateElection(ElectionSetupModel election)
        {
            using (var electionRepository = new ElectionRepository())
            {
                var electionToUpdate = new Election
                {
                    ElectionId = ElectionConductor.ElectionId((int) Session["UserId"]),
                    Name = election.Name,
                    MinVotes = election.MinVotes,
                    MaxVotes = election.MaxVotes,
                    NoVote = election.NoVote
                };

                var result = electionRepository.UpdateElectionSetup(electionToUpdate);

                return new JsonResult
                {
                    Data = new { isOk = result }
                };
            }
        }
Exemple #39
0
        public void Identity(string roundName)
        {
            if (electionDict.ContainsKey(roundName))
            {
                return;
            }

            var roundsRoot = string.Format("/{0}Rounds", RoutingRule.DistrictsName);
            var thisRound = string.Format("{0}/{1}", roundsRoot, roundName);
            try
            {
                handle.Create(roundsRoot, null, Ids.OPEN_ACL_UNSAFE, CreateMode.Persistent);
            }
            catch (KeeperException.NodeExistsException e)
            {
                // ignore
            }

            try
            {
                handle.Create(thisRound, null, Ids.OPEN_ACL_UNSAFE, CreateMode.Persistent);
            }
            catch (KeeperException.NodeExistsException e)
            {
                // ignore
            }

            var me = string.Format("{0}/{1}-n_", thisRound, uuid);
            var ret = handle.Create(me, null, Ids.OPEN_ACL_UNSAFE, CreateMode.EphemeralSequential);

            var elect = new Election(handle, thisRound, roundName, Election.PathToSeq(ret));

            electionDict[roundName] = elect;
            elect.AttempToBecomeLeader();
        }
Exemple #40
0
 void Awake()
 {
     instance = this;
 }
        public LeaderBaseTests()
        {
            var mocker = new AutoMocker();

            ServerIdentifier = new ServerIdentifier();
            mocker.Use(ServerIdentifier);

            Election = new Election();
            AppendEntryResult = new Subject<AppendEntryResultMessage>();
            AppendEntry = new Subject<AppendEntryMessage>();
            LogReplication = new LogReplication();
            Nodes = new Nodes();

            Leader = new Rafting.States.Leader(
                Election,
                mocker.Get<IHartbeatTimer>(),
                AppendEntryResult,
                AppendEntry,
                mocker.Get<IObserver<ClientResultMessage>>(),
                mocker.Get<IObservable<ClientMessage>>(),
                LogReplication,
                Nodes,
                mocker.Get<ILoggerFactory>(),
                new RaftOptions(),
                mocker.Get<ServerIdentifier>());
        }