test/unit/ut_7_workitem.rb in ruote-2.1.6 vs test/unit/ut_7_workitem.rb in ruote-2.1.7

- old
+ new

@@ -11,11 +11,38 @@ require 'ruote/workitem' class UtWorkitemTest < Test::Unit::TestCase - def test_zero + def test_equality - assert true + f0 = { 'expid' => '0', 'wfid' => '20101224-baba', 'engine_id' => 'engine' } + f1 = { 'expid' => '0', 'wfid' => '20101224-baba', 'engine_id' => 'engine' } + f2 = { 'expid' => '1', 'wfid' => '20101224-baba', 'engine_id' => 'engine' } + + w0 = Ruote::Workitem.new('fei' => f0, 'fields' => { 'a' => 'A' }) + w1 = Ruote::Workitem.new('fei' => f1, 'fields' => { 'b' => 'B' }) + w2 = Ruote::Workitem.new('fei' => f2, 'fields' => { 'c' => 'C' }) + + assert w0 == w1 + assert w0 != w2 + + assert_equal w0.hash, w1.hash + assert_not_equal w0.hash, w2.hash + end + + def test_lookup + + w0 = Ruote::Workitem.new( + 'fields' => { + 'customer' => { + 'name' => 'Jeff', + 'address' => [ 'Cornwall Square 10', 'Singapore-La' ] } }) + + assert_equal 'Jeff', w0.lookup('customer.name') + assert_equal 'Singapore-La', w0.lf('customer.address.1') + + w0.set_field('customer.address', [ 'Cornwall Square 10b', 'Singapore-La' ]) + assert_equal 'Cornwall Square 10b', w0.lookup('customer.address.0') end end