WalletTest - @w.addCoin(@penny) @w.addCoin(@penny)

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
require "test/unit" require 'Wallet' require 'Coin' #coded by srihari jagan vasista # Test cases of the wallet class class WalletTest < Test::Unit::TestCase c def setup @w = Wallet.new; @penny = Coin.new("penny",1) end def test_default_Wallet_addCoin @wa = Wallet.new @wa.addCoin(@penny); @wa.addCoin(@penny); @wa.addCoin(@penny); assert_equal(3,@wa.getCount(@penny)) end e def test_default_Wallet_equals assert_equal(true,equals(a = Coin.new("dime",10), b = Coin.new("dime",10))) end e def test_default_Wallet_removeCoin @w.addCoin(@penny) @w.addCoin(@penny) assert_equal(2,@w.getCount(@penny)) @w.removeCoin(@penny) @w.addCoin(@penny) @w.removeCoin(@penny) @w.removeCoin(@penny) assert_equal(0,@w.getCount(@penny)) end e def test_default_wallet_printContent
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: @w.addCoin(@penny) @w.addCoin(@penny) assert_equal(2,@w.getCount(@penny)) @w.removeCoin(@penny) @w.addCoin(@penny) @w.removeCoin(@penny) @w.addCoin(@penny) @content = @w.printContent() assert_equal(true,@content.include?(&quot;penny&quot;)) end e end e begin @name = &quot;&quot; @wal = Wallet.new @ begin puts &quot;enter the coin name&quot; @name =&quot;&quot; @name = gets() if(@name.eql?(&quot;\n&quot;)) then break end puts &quot;enter the coinValue&quot; @value_s = &quot;&quot;;@value = 0 @value_s = gets() if(!@value_s.empty?)then @value = @value_s.to_i(base=10) end if (!@name.empty? and @value &gt; 0) then @c = Coin.new(@name,@value) end @wal.addCoin(@c) end until(@name.eql?(&quot;\n&quot;)) @wal.printContent() @ end...
View Full Document

Page1 / 2

WalletTest - @w.addCoin(@penny) @w.addCoin(@penny)

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online