From 2ff296ba6cabf56472fdd93a031b3d775b6dfc5f Mon Sep 17 00:00:00 2001 From: David Smith Date: Tue, 15 Dec 2015 22:40:24 -0600 Subject: [PATCH] Update tests. --- TallyUnitTest/VoteConstructorTests.cs | 88 +++++++++++++++------------ TallyUnitTest/VoteCounterTests.cs | 4 ++ 2 files changed, 53 insertions(+), 39 deletions(-) diff --git a/TallyUnitTest/VoteConstructorTests.cs b/TallyUnitTest/VoteConstructorTests.cs index 2c7749d2..f6539cfc 100644 --- a/TallyUnitTest/VoteConstructorTests.cs +++ b/TallyUnitTest/VoteConstructorTests.cs @@ -23,6 +23,7 @@ public static void ClassInit(TestContext context) public void Initialize() { VoteCounter.Instance.Reset(); + VoteCounter.Instance.PostsList.Clear(); sampleQuest.AllowRankedVotes = false; sampleQuest.PartitionMode = PartitionMode.None; } @@ -150,7 +151,8 @@ [x] Head over to Oriko's. -[x] Light conversation. No need for serious precog questions right now."; string author = "Muramasa"; string postId = "123456"; - PostComponents p1 = new PostComponents(author, postId, testVote); + int postNumber = 100; + PostComponents p1 = new PostComponents(author, postId, testVote, postNumber); p1.SetWorkingVote(voteConstructor.GetWorkingVote); voteConstructor.ProcessPost(p1, sampleQuest); @@ -158,10 +160,13 @@ [x] Head over to Oriko's. string referralVote = @"[x] Muramasa"; string refAuthor = "Gerbil"; string refID = "123457"; - PostComponents p2 = new PostComponents(refAuthor, refID, referralVote); - p2.SetWorkingVote(voteConstructor.GetWorkingVote); + int refPostNum = 101; + PostComponents p2 = new PostComponents(refAuthor, refID, referralVote, refPostNum); + + VoteCounter.Instance.PostsList.Add(p1); + VoteCounter.Instance.PostsList.Add(p2); - voteConstructor.ProcessPost(p2, sampleQuest); + VoteCounter.Instance.TallyPosts(sampleQuest); var votes = VoteCounter.Instance.GetVotesCollection(VoteType.Vote); var voters = VoteCounter.Instance.GetVotersCollection(VoteType.Vote); @@ -185,18 +190,19 @@ [x] Head over to Oriko's. string author = "Muramasa"; string postId = "123456"; - PostComponents p1 = new PostComponents(author, postId, testVote); - p1.SetWorkingVote(voteConstructor.GetWorkingVote); - - voteConstructor.ProcessPost(p1, sampleQuest); + int postNumber = 100; + PostComponents p1 = new PostComponents(author, postId, testVote, postNumber); string referralVote = @"[x] Muramasa"; string refAuthor = "Gerbil"; string refID = "123457"; - PostComponents p2 = new PostComponents(refAuthor, refID, referralVote); - p2.SetWorkingVote(voteConstructor.GetWorkingVote); + int refPostNum = 101; + PostComponents p2 = new PostComponents(refAuthor, refID, referralVote, refPostNum); + + VoteCounter.Instance.PostsList.Add(p1); + VoteCounter.Instance.PostsList.Add(p2); - voteConstructor.ProcessPost(p2, sampleQuest); + VoteCounter.Instance.TallyPosts(sampleQuest); var votes = VoteCounter.Instance.GetVotesCollection(VoteType.Vote); var voters = VoteCounter.Instance.GetVotersCollection(VoteType.Vote); @@ -220,18 +226,19 @@ [x] Head over to Oriko's. string author = "Muramasa"; string postId = "123456"; - PostComponents p1 = new PostComponents(author, postId, testVote); - p1.SetWorkingVote(voteConstructor.GetWorkingVote); - - voteConstructor.ProcessPost(p1, sampleQuest); + int postNumber = 100; + PostComponents p1 = new PostComponents(author, postId, testVote, postNumber); string referralVote = @"[x] Muramasa"; string refAuthor = "Gerbil"; string refID = "123457"; - PostComponents p2 = new PostComponents(refAuthor, refID, referralVote); - p2.SetWorkingVote(voteConstructor.GetWorkingVote); + int refPostNum = 101; + PostComponents p2 = new PostComponents(refAuthor, refID, referralVote, refPostNum); - voteConstructor.ProcessPost(p2, sampleQuest); + VoteCounter.Instance.PostsList.Add(p1); + VoteCounter.Instance.PostsList.Add(p2); + + VoteCounter.Instance.TallyPosts(sampleQuest); var votes = VoteCounter.Instance.GetVotesCollection(VoteType.Vote); var voters = VoteCounter.Instance.GetVotersCollection(VoteType.Vote); @@ -255,19 +262,20 @@ [x] Head over to Oriko's. -[x] Light conversation. No need for serious precog questions right now."; string author = "Muramasa"; string postId = "123456"; - PostComponents p1 = new PostComponents(author, postId, testVote); - p1.SetWorkingVote(voteConstructor.GetWorkingVote); - - voteConstructor.ProcessPost(p1, sampleQuest); + int postNumber = 100; + PostComponents p1 = new PostComponents(author, postId, testVote, postNumber); string referralVote = @"[x] Muramasa [x] With Cake"; string refAuthor = "Gerbil"; string refID = "123457"; - PostComponents p2 = new PostComponents(refAuthor, refID, referralVote); - p2.SetWorkingVote(voteConstructor.GetWorkingVote); + int refPostNum = 101; + PostComponents p2 = new PostComponents(refAuthor, refID, referralVote, refPostNum); - voteConstructor.ProcessPost(p2, sampleQuest); + VoteCounter.Instance.PostsList.Add(p1); + VoteCounter.Instance.PostsList.Add(p2); + + VoteCounter.Instance.TallyPosts(sampleQuest); var votes = VoteCounter.Instance.GetVotesCollection(VoteType.Vote); var voters = VoteCounter.Instance.GetVotersCollection(VoteType.Vote); @@ -291,19 +299,20 @@ [x] Head over to Oriko's. string author = "Muramasa"; string postId = "123456"; - PostComponents p1 = new PostComponents(author, postId, testVote); - p1.SetWorkingVote(voteConstructor.GetWorkingVote); - - voteConstructor.ProcessPost(p1, sampleQuest); + int postNumber = 100; + PostComponents p1 = new PostComponents(author, postId, testVote, postNumber); string referralVote = @"[x] Muramasa [x] With Cake"; string refAuthor = "Gerbil"; string refID = "123457"; - PostComponents p2 = new PostComponents(refAuthor, refID, referralVote); - p2.SetWorkingVote(voteConstructor.GetWorkingVote); + int refPostNum = 101; + PostComponents p2 = new PostComponents(refAuthor, refID, referralVote, refPostNum); - voteConstructor.ProcessPost(p2, sampleQuest); + VoteCounter.Instance.PostsList.Add(p1); + VoteCounter.Instance.PostsList.Add(p2); + + VoteCounter.Instance.TallyPosts(sampleQuest); var votes = VoteCounter.Instance.GetVotesCollection(VoteType.Vote); var voters = VoteCounter.Instance.GetVotersCollection(VoteType.Vote); @@ -328,19 +337,20 @@ [x] Head over to Oriko's. string author = "Muramasa"; string postId = "123456"; - PostComponents p1 = new PostComponents(author, postId, testVote); - p1.SetWorkingVote(voteConstructor.GetWorkingVote); - - voteConstructor.ProcessPost(p1, sampleQuest); + int postNumber = 100; + PostComponents p1 = new PostComponents(author, postId, testVote, postNumber); string referralVote = @"[x] Muramasa [x] With Cake"; string refAuthor = "Gerbil"; string refID = "123457"; - PostComponents p2 = new PostComponents(refAuthor, refID, referralVote); - p2.SetWorkingVote(voteConstructor.GetWorkingVote); + int refPostNum = 101; + PostComponents p2 = new PostComponents(refAuthor, refID, referralVote, refPostNum); + + VoteCounter.Instance.PostsList.Add(p1); + VoteCounter.Instance.PostsList.Add(p2); - voteConstructor.ProcessPost(p2, sampleQuest); + VoteCounter.Instance.TallyPosts(sampleQuest); var votes = VoteCounter.Instance.GetVotesCollection(VoteType.Vote); var voters = VoteCounter.Instance.GetVotersCollection(VoteType.Vote); diff --git a/TallyUnitTest/VoteCounterTests.cs b/TallyUnitTest/VoteCounterTests.cs index abef38a7..b1309d0d 100644 --- a/TallyUnitTest/VoteCounterTests.cs +++ b/TallyUnitTest/VoteCounterTests.cs @@ -466,6 +466,8 @@ public void FindVotesForVoterTest1() VoteCounter.Instance.AddVotes(vote1, voter1, postId1, voteType); VoteCounter.Instance.AddVotes(vote2, voter2, postId2, voteType); + VoteCounter.Instance.ReferenceVoters.Add(voter1); + VoteCounter.Instance.ReferenceVoters.Add(voter2); var votes = VoteCounter.Instance.GetVotesFromReference("[x] me", "Him"); Assert.AreEqual(1, votes.Count); @@ -487,6 +489,8 @@ public void FindVotesForVoterTest2() VoteCounter.Instance.AddVotes(vote1, voter1, postId1, voteType); VoteCounter.Instance.AddVotes(vote2, voter2, postId2, voteType); + VoteCounter.Instance.ReferenceVoters.Add(voter1); + VoteCounter.Instance.ReferenceVoters.Add(voter2); var votes = VoteCounter.Instance.GetVotesFromReference("[x] you", "Him"); Assert.AreEqual(2, votes.Count);