Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinematics committed Dec 16, 2015
1 parent 803aa21 commit 2ff296b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 39 deletions.
88 changes: 49 additions & 39 deletions TallyUnitTest/VoteConstructorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -150,18 +151,22 @@ [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);

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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions TallyUnitTest/VoteCounterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 2ff296b

Please sign in to comment.