Example #1
0
        public async Task TestVoteRandomOnPoll(int pollId, int answerId)
        {
            Poll poll;
            IEnumerable <Vote> votesBefore;

            // Create poll
            using (var service = Statics.NewService())
            {
                poll = await service.GetPollByIdAsync(pollId);

                votesBefore = await service.GetVotesForPollAsync(poll);

                var answers = await service.GetAnswersForPollAsync(poll);

                await service.VoteOnPoll(CurrentUser, poll, answers[answerId]);
            }

            // Compare votes
            using (var service = Statics.NewService())
            {
                IEnumerable <Vote> votesAfter = await service.GetVotesForPollAsync(poll);

                // after should be more
                Assert.NotEqual(votesAfter.Count(), votesBefore.Count());
            }
        }
Example #2
0
        public async Task TestCreateUser(string name, string email)
        {
            User user;

            // Create user
            using (var service = Statics.NewService())
            {
                user = await service.RegisterAsync(email, name, Random.Next(1111111, 9999999).ToString());

                await service.SaveAsync();
            }

            // Find user
            using (var service = Statics.NewService())
            {
                var foundUser = await service.GetUserByIdAsync(user.Id);

                Assert.NotNull(foundUser);
                Assert.Equal(user.Id, foundUser.Id);
            }
        }
Example #3
0
        public async Task TestCreateTextPoll(string title, params string[] answers)
        {
            Poll poll;

            // Create poll
            using (var service = Statics.NewService())
            {
                var textAnswers = answers.Select(a => new TextAnswer(a));
                poll = await service.CreatePollAsync(CurrentUser, title, DateTime.Now.AddDays(10), textAnswers);

                await service.SaveAsync();
            }

            // Find poll
            using (var service = Statics.NewService())
            {
                var foundPoll = await service.GetPollByIdAsync(poll.Id);

                Assert.NotNull(foundPoll);
                Assert.Equal(poll.Id, foundPoll.Id);
            }
        }
Example #4
0
        public async Task TestVotes(string title, params string[] answers)
        {
            IList <DoodlerCore.Vote> vote;
            Poll poll;

            // Create poll
            using (var service = Statics.NewService())
            {
                var textAnswers = answers.Select(answer => new TextAnswer(answer));
                poll = await service.CreatePollAsync(CurrentUser, title, DateTime.Now.AddDays(10), textAnswers);

                await service.SaveAsync();
            }



            //Checking Votes
            using (var service = Statics.NewService())
            {
                vote = await service.GetVotesForPollAsync(poll);
            }
            Assert.NotEmpty(vote);
        }
Example #5
0
        public async Task TestDeleteTextPoll(string title, params string[] answers)
        {
            Poll poll;

            // Create poll
            using (var service = Statics.NewService())
            {
                var textAnswers = answers.Select(a => new TextAnswer(a));
                poll = await service.CreatePollAsync(CurrentUser, title, DateTime.Now.AddDays(10), textAnswers);

                IList <Answer> pollAnwers;
                pollAnwers = await service.GetAnswersForPollAsync(poll);

                foreach (var answer in pollAnwers)
                {
                    await service.DeleteAnswerAsync(answer);
                }

                await service.DeletePollAsync(poll);

                await service.SaveAsync();
            }
        }