Exemple #1
0
        private bool CheckIfUserHasVoted(string pollId)
        {
            bool hasVoted    = false;
            var  cookieValue = _requestHeaderHandler.GetCookie(ControllerContext, pollId);

            if (cookieValue == pollId)
            {
                hasVoted = true;
            }

            return(hasVoted);
        }
        public async Task Submit_ReturnsBadRequestIfUserAlreadyVoted()
        {
            string pollId = "someId";

            _requestHeaderHandler.GetCookie(_pollRendererController.ControllerContext, pollId).Returns(pollId);
            var result = await _pollRendererController.SubmitVote(new VoteRequest()
            {
                PollId        = pollId,
                SelectedVotes = new List <VoteDto>()
                {
                    new VoteDto()
                    {
                        Count = 1
                    }
                }
            });

            Assert.IsInstanceOf <BadRequestResult>(result);
        }