Esempio n. 1
0
        public void CalculateOneSidedOutcome()
        {
            CheckForZeroOptions();
            _selectedVoteDistribution = new OneSidedVoteDistribution();

            _selectedVoteDistribution.DistributeVotes(this);
        }
Esempio n. 2
0
 private void DetermineVoteDistributionStrategy()
 {
     if (_options.Any(option => option.PreferredNumberOfVotes > 0))
     {
         _selectedVoteDistribution = new FixedVoteDistribution();
     }
     else
     {
         _selectedVoteDistribution = new RandomVoteDistribution();
     }
 }
Esempio n. 3
0
        public Survey CalculateOutcome(IVoteDistribution strategy)
        {
            if (!_options.Any())
            {
                throw new SurveyDomainException("Cannot calculate a survey with no options");
            }

            strategy.DistributeVotes(this);

            return(this);
        }
Esempio n. 4
0
        }                    // Necessary for Entity Framework Core

        public Survey(User owner, NonEmptyString topic, int numberOfRespondents, NonEmptyString respondentType)
        {
            if (numberOfRespondents < 1)
            {
                throw new SurveyDomainException("Survey should have at least one respondent");
            }

            Owner               = owner ?? throw new ArgumentNullException(nameof(owner));
            Topic               = topic ?? throw new ArgumentNullException(nameof(topic));
            RespondentType      = respondentType ?? throw new ArgumentNullException(nameof(respondentType));
            NumberOfRespondents = numberOfRespondents;

            _selectedVoteDistribution = new RandomVoteDistribution();

            AddSurveyCreatedEvent();
        }