private Vote PrepareRunningVote() { Vote vote = new Vote(); List<Mock<IVoter>> voterMocks = GenenerateVoterMocks(10); List<TaskCompletionSource<bool>> votingCompletionSources = SetupRequestVoteMethods(voterMocks); Task<bool> votingTask = vote.CallVote(voterMocks.Select(mock => mock.Object)); Assert.AreEqual(TaskStatus.WaitingForActivation, votingTask.Status); return vote; }
private Vote PrepareCompletedVote() { Vote vote = new Vote(); List<Mock<IVoter>> voterMocks = GenenerateVoterMocks(10); List<TaskCompletionSource<bool>> votingCompletionSources = SetupRequestVoteMethods(voterMocks); Task<bool> votingTask = vote.CallVote(voterMocks.Select(mock => mock.Object)); CompleteVotesInParallel(votingCompletionSources, true); Assert.IsTrue(votingTask.Wait(TimeoutForVotesToBeCounted)); return vote; }