Sha256: 490b5a403c9c39f6acb4e8076d3cc27a05f6354d3e73212804f99223411e5948

Contents?: true

Size: 1.73 KB

Versions: 2

Compression:

Stored size: 1.73 KB

Contents

#
# Testing OpenWFE
#
# John Mettraux at openwfe.org
#
# Tue Mar 11 13:44:11 JST 2008
#

require 'test/unit'

require 'rubygems'
require 'openwfe/workitem'
require 'openwfe/expressions/expressionmap'


class LookupVfTest < Test::Unit::TestCase

    #def setup
    #end

    #def teardown
    #end


    def test_0

        fexp = new_exp({
            "on-value" => "toto"
        })
        wi = new_wi({
            "toto" => "whatever"
        })

        assert_equal(
            "toto", 
            fexp.lookup_vf_attribute(wi, "value", :prefix => "on"))

        fexp = new_exp({ "on-variable-value" => "toto" }, { "toto" => "surf" })

        assert_equal(
            "surf", 
            fexp.lookup_vf_attribute(wi, "value", :prefix => "on"))

        fexp = new_exp({ "on-field-value" => "toto" })

        assert_equal(
            "whatever", 
            fexp.lookup_vf_attribute(wi, "value", :prefix => "on"))
    end

    def test_1

        fexp = new_exp({
            "on" => "surf"
        })
        wi = new_wi

        assert_equal(
            "surf", 
            fexp.lookup_vf_attribute(wi, "", :prefix => "on"))

        assert_equal(
            "surf", 
            fexp.lookup_vf_attribute(wi, "", :prefix => :on))
    end

    protected

        def new_exp (atts, vars={})

            fexp = OpenWFE::ParticipantExpression.new
            fexp.attributes = atts

            fexp.instance_variable_set :@vars, vars

            class << fexp
                def lookup_variable (var_name)
                    @vars[var_name]
                end
            end

            fexp
        end

        def new_wi (atts={})

            wi = OpenWFE::InFlowWorkItem.new
            wi.attributes = atts
            wi
        end

end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
openwferu-0.9.17 test/lookup_vf_test.rb
ruote-0.9.18 test/lookup_vf_test.rb