From 94f9b1405c2eefc97faf91ad14ec775584fca65a Mon Sep 17 00:00:00 2001 From: John Dong Date: Fri, 17 Aug 2007 14:04:04 -0400 Subject: [PATCH 1/1] Add some testcases: * Create a new quickvote * Retrieve a quickvote * Casting a quickvote --- test/unit/selectricityservice_test.rb | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/unit/selectricityservice_test.rb b/test/unit/selectricityservice_test.rb index 631110a..2560fda 100644 --- a/test/unit/selectricityservice_test.rb +++ b/test/unit/selectricityservice_test.rb @@ -13,4 +13,32 @@ class SelectricityServiceTest < Test::Unit::TestCase assert_instance_of Array, result assert_equal result.length, 0 end + def test_create_quickvote + election = ElectionStruct.new :name => "TestVote", :description => "Test Vote", :candidate_names => ["Apple", "Orange", "Banana", "Pineapple"] + result = invoke_delegated :vote, :create_quickvote, election + assert_instance_of String, result + assert_equal "", result + assert_equal(invoke_delegated(:vote,:list_quickvotes).length, 1) + end + def test_get_quickvote + test_create_quickvote + result = invoke_delegated :vote, :get_quickvote, "TestVote" + assert_instance_of ElectionStruct, result + assert_equal 0, result.name.casecmp("TestVote") + assert_equal result.description, "Test Vote" + assert_equal result.candidate_names.sort, ["Apple", "Orange", "Banana", "Pineapple"].sort + assert_not_nil result.id + assert result.id != 0 + assert_nil result.candidate_ids.uniq! + assert result.candidate_ids.length == result.candidate_names.length + end + def test_cast_quickvote + test_create_quickvote + election = invoke_delegated :vote, :get_quickvote, "TestVote" + casted_vote = election.candidate_ids.sort_by {rand} #Shuffles + invoke_delegated :vote, :cast_quickvote, "TestVote", 42, [casted_vote] + quickvote_votes= invoke_delegated :vote, :get_quickvote_votes, "TestVote" + assert_equal quickvote_votes.length, 1 + assert_equal quickvote_votes[0].vote, casted_vote + end end -- 2.39.5