Beispiel #1
0
        public void AddPlanTypeVoteTest()
        {
            string        voteLine = "[x] First test";
            string        voter    = "me";
            string        planname = "◈PlanPlan";
            string        postId   = "1";
            List <string> vote     = new List <string> {
                voteLine
            };
            VoteType voteType = VoteType.Plan;

            voteCounter.AddVotes(vote, planname, postId, voteType);
            voteCounter.AddVotes(vote, voter, postId, VoteType.Vote);

            Assert.IsTrue(voteCounter.GetVotesCollection(voteType).Keys.Contains(voteLine));
            Assert.IsTrue(voteCounter.GetVotesCollection(voteType)[voteLine].Contains(voter));
            Assert.IsTrue(voteCounter.GetVotesCollection(voteType)[voteLine].Contains(planname));

            Assert.IsTrue(voteCounter.GetVotersCollection(voteType).ContainsKey(voter));
            Assert.IsTrue(voteCounter.GetVotersCollection(voteType).ContainsKey(planname));
            Assert.AreEqual(postId, voteCounter.GetVotersCollection(voteType)[voter]);
            Assert.AreEqual(postId, voteCounter.GetVotersCollection(voteType)[planname]);

            Assert.IsTrue(voteCounter.HasPlan("PlanPlan"));
        }
Beispiel #2
0
        public async Task Check_Tally_Adds_Plan()
        {
            string postText1 =
                @"[X] Plan Experiment
-[X] This is fine by you.
--[X] At least for today.";
            string postText2 =
                @"[X] Save it for another day.
[X] This is fine by you.
-[X] At least for today.";

            Post post1 = new Post(origin1, postText1);
            Post post2 = new Post(origin2, postText2);

            Assert.IsTrue(post1.HasVote);
            Assert.IsTrue(post2.HasVote);

            List <Post> posts = new List <Post>()
            {
                post1, post2
            };

            quest.PartitionMode = PartitionMode.None;

            await tally.TallyPosts(posts, quest, CancellationToken.None);

            List <VoteLineBlock> allVotes = voteCounter.VoteStorage.GetAllVotes().ToList();

            Assert.AreEqual(2, allVotes.Count);
            Assert.AreEqual(3, allVotes[0].Lines.Count);
            Assert.AreEqual(3, allVotes[1].Lines.Count);

            Assert.IsTrue(voteCounter.HasVoter(origin1.Author));
            Assert.IsTrue(voteCounter.HasVoter(origin2.Author));
            Assert.IsTrue(voteCounter.HasPlan("Experiment"));

            var vote1 = voteCounter.VoteStorage.GetVotesBy(origin1);

            Assert.AreEqual(1, vote1.Count);

            var voters1 = voteCounter.GetVotersFor(vote1[0]);

            Assert.AreEqual(2, voters1.Count());
        }