Пример #1
0
        public void When_user_voted_today_for_project_HasUserVotedToday_returns_true()
        {
            var vote = CreateVote();
            var hasUserVotedToday = repo.HasUserVotedToday(vote.UserId, vote.ProjectId, vote.SocialName);

            Assert.True(hasUserVotedToday);
        }
Пример #2
0
        public virtual void AddVote(int projectId, string userId, string socialName)
        {
            socialName = socialName.ToLower();

            if (socialName != "facebook" &&
                socialName != "draugiem")
            {
                throw new InvalidSocialMediaException();
            }

            if (repo.HasUserVotedToday(userId, projectId, socialName))
            {
                throw new UserAlreadyVotedException();
            }

            var vote = new Vote
            {
                UserId         = userId,
                ProjectId      = projectId,
                VotingDateTime = DateTime.Now,
                SocialName     = socialName
            };

            repo.Add(vote);
        }