+ def assert_cast_quickvote_succeeds(shortname, id, vote)
+ assert_nothing_raised do
+ old_votes = invoke_delegated(:vote, :get_quickvote_votes, shortname)
+ invoke_delegated(:vote, :cast_quickvote, shortname, id, vote)
+
+ new_votes = invoke_delegated(:vote, :get_quickvote_votes, shortname)
+ assert_equal(old_votes.length, new_votes.length - 1)
+
+ reflection = new_votes.find_all { |v| v.voter_session_id == "XMLRPC:#{id}" }
+ assert_not_nil(reflection)
+ assert_equal(reflection.length, 1)
+ assert_equal(reflection[0].vote, vote[0])
+ end
+ end
+
+ def assert_cast_quickvote_fails(shortname, id, vote)
+ assert_raise Test::Unit::AssertionFailedError do
+ assert_cast_quickvote_succeeds(shortname, id, vote)
+ end
+ end
+
+ def assert_create_quickvote_succeeds(election)
+ # checks if a created quickvote is identical when retrieved
+ assert_nothing_raised do
+ old_len = invoke_delegated(:vote, :list_quickvotes).length
+ result = invoke_delegated(:vote, :create_quickvote, election)
+ assert_equal(result, "")
+
+ reflection = invoke_delegated(:vote, :get_quickvote, election.name)
+ assert_equal(election.description, reflection.description)
+ assert_equal(0, election.name.casecmp(reflection.name))
+ assert_equal(election.candidate_names, reflection.candidate_names)
+ assert_equal(invoke_delegated(:vote, :list_quickvotes).length, old_len+1)
+ end
+ end
+